feb725437b2217eb6d8dea5c267cb5240de4ce43
[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
159 static inline void* untag_ptr(uint64_t ptr) {
160         if (ptr < 4096) return (void*)ptr;
161         if (sizeof(void*) == 4) {
162                 // For 32-bit systems, store pointers as 64-bit ints and use the 31st bit
163                 return (void*)(uintptr_t)ptr;
164         } else {
165                 // For 64-bit systems, assume the top byte is used for tagging, then
166                 // use bit 9 ^ bit 10.
167                 uint64_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
168                 uintptr_t p = (ptr & ~(1ULL << 55)) | (tenth_bit << 55);
169 #ifdef LDK_DEBUG_BUILD
170                 // On debug builds we also use the 11th bit as a debug flag
171                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
172                 CHECK(tenth_bit != eleventh_bit);
173                 p ^= 1ULL << 53;
174 #endif
175                 return (void*)p;
176         }
177 }
178 static inline bool ptr_is_owned(uint64_t ptr) {
179         if(ptr < 4096) return true;
180         if (sizeof(void*) == 4) {
181                 return ptr & (1ULL << 32);
182         } else {
183                 uintptr_t ninth_bit = (((uintptr_t)ptr) & (1ULL << 55)) >> 55;
184                 uintptr_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
185 #ifdef LDK_DEBUG_BUILD
186                 // On debug builds we also use the 11th bit as a debug flag
187                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
188                 CHECK(tenth_bit != eleventh_bit);
189 #endif
190                 return (ninth_bit ^ tenth_bit) ? true : false;
191         }
192 }
193 static inline uint64_t tag_ptr(const void* ptr, bool is_owned) {
194         if ((uintptr_t)ptr < 4096) return (uint64_t)ptr;
195         if (sizeof(void*) == 4) {
196                 return (((uint64_t)ptr) | ((is_owned ? 1ULL : 0) << 32));
197         } else {
198                 CHECK(sizeof(uintptr_t) == 8);
199                 uintptr_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
200                 uintptr_t t = (((uintptr_t)ptr) | (((is_owned ? 1ULL : 0ULL) ^ tenth_bit) << 55));
201 #ifdef LDK_DEBUG_BUILD
202                 uintptr_t ninth_bit = (((uintptr_t)ptr) & (1ULL << 55)) >> 55;
203                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
204                 CHECK(ninth_bit == tenth_bit);
205                 CHECK(ninth_bit == eleventh_bit);
206                 t ^= 1ULL << 53;
207 #endif
208                 CHECK(ptr_is_owned(t) == is_owned);
209                 CHECK(untag_ptr(t) == ptr);
210                 return t;
211         }
212 }
213
214 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
215         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
216         if (UNLIKELY((*env)->ExceptionCheck(env))) {
217                 (*env)->ExceptionDescribe(env);
218                 (*env)->FatalError(env, "A call to AccessError.ordinal() from rust threw an exception.");
219         }
220         switch (ord) {
221                 case 0: return LDKAccessError_UnknownChain;
222                 case 1: return LDKAccessError_UnknownTx;
223         }
224         (*env)->FatalError(env, "A call to AccessError.ordinal() from rust returned an invalid value.");
225         abort(); // Unreachable, but will let the compiler know we don't return here
226 }
227 static jclass AccessError_class = NULL;
228 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
229 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
230 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
231         AccessError_class = (*env)->NewGlobalRef(env, clz);
232         CHECK(AccessError_class != NULL);
233         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
234         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
235         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
236         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
237 }
238 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
239         switch (val) {
240                 case LDKAccessError_UnknownChain:
241                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
242                 case LDKAccessError_UnknownTx:
243                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
244                 default: abort();
245         }
246 }
247
248 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_java(JNIEnv *env, jclass clz) {
249         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
250         if (UNLIKELY((*env)->ExceptionCheck(env))) {
251                 (*env)->ExceptionDescribe(env);
252                 (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust threw an exception.");
253         }
254         switch (ord) {
255                 case 0: return LDKCOption_NoneZ_Some;
256                 case 1: return LDKCOption_NoneZ_None;
257         }
258         (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust returned an invalid value.");
259         abort(); // Unreachable, but will let the compiler know we don't return here
260 }
261 static jclass COption_NoneZ_class = NULL;
262 static jfieldID COption_NoneZ_LDKCOption_NoneZ_Some = NULL;
263 static jfieldID COption_NoneZ_LDKCOption_NoneZ_None = NULL;
264 JNIEXPORT void JNICALL Java_org_ldk_enums_COption_1NoneZ_init (JNIEnv *env, jclass clz) {
265         COption_NoneZ_class = (*env)->NewGlobalRef(env, clz);
266         CHECK(COption_NoneZ_class != NULL);
267         COption_NoneZ_LDKCOption_NoneZ_Some = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_Some", "Lorg/ldk/enums/COption_NoneZ;");
268         CHECK(COption_NoneZ_LDKCOption_NoneZ_Some != NULL);
269         COption_NoneZ_LDKCOption_NoneZ_None = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_None", "Lorg/ldk/enums/COption_NoneZ;");
270         CHECK(COption_NoneZ_LDKCOption_NoneZ_None != NULL);
271 }
272 static inline jclass LDKCOption_NoneZ_to_java(JNIEnv *env, LDKCOption_NoneZ val) {
273         switch (val) {
274                 case LDKCOption_NoneZ_Some:
275                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_Some);
276                 case LDKCOption_NoneZ_None:
277                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_None);
278                 default: abort();
279         }
280 }
281
282 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
283         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
284         if (UNLIKELY((*env)->ExceptionCheck(env))) {
285                 (*env)->ExceptionDescribe(env);
286                 (*env)->FatalError(env, "A call to ChannelMonitorUpdateErr.ordinal() from rust threw an exception.");
287         }
288         switch (ord) {
289                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
290                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
291         }
292         (*env)->FatalError(env, "A call to ChannelMonitorUpdateErr.ordinal() from rust returned an invalid value.");
293         abort(); // Unreachable, but will let the compiler know we don't return here
294 }
295 static jclass ChannelMonitorUpdateErr_class = NULL;
296 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
297 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
298 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
299         ChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
300         CHECK(ChannelMonitorUpdateErr_class != NULL);
301         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
302         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
303         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
304         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
305 }
306 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
307         switch (val) {
308                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
309                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
310                 case LDKChannelMonitorUpdateErr_PermanentFailure:
311                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
312                 default: abort();
313         }
314 }
315
316 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
317         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
318         if (UNLIKELY((*env)->ExceptionCheck(env))) {
319                 (*env)->ExceptionDescribe(env);
320                 (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust threw an exception.");
321         }
322         switch (ord) {
323                 case 0: return LDKConfirmationTarget_Background;
324                 case 1: return LDKConfirmationTarget_Normal;
325                 case 2: return LDKConfirmationTarget_HighPriority;
326         }
327         (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust returned an invalid value.");
328         abort(); // Unreachable, but will let the compiler know we don't return here
329 }
330 static jclass ConfirmationTarget_class = NULL;
331 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
332 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
333 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
334 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
335         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
336         CHECK(ConfirmationTarget_class != NULL);
337         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
338         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
339         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
340         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
341         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
342         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
343 }
344 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
345         switch (val) {
346                 case LDKConfirmationTarget_Background:
347                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
348                 case LDKConfirmationTarget_Normal:
349                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
350                 case LDKConfirmationTarget_HighPriority:
351                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
352                 default: abort();
353         }
354 }
355
356 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
357         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
358         if (UNLIKELY((*env)->ExceptionCheck(env))) {
359                 (*env)->ExceptionDescribe(env);
360                 (*env)->FatalError(env, "A call to CreationError.ordinal() from rust threw an exception.");
361         }
362         switch (ord) {
363                 case 0: return LDKCreationError_DescriptionTooLong;
364                 case 1: return LDKCreationError_RouteTooLong;
365                 case 2: return LDKCreationError_TimestampOutOfBounds;
366                 case 3: return LDKCreationError_InvalidAmount;
367                 case 4: return LDKCreationError_MissingRouteHints;
368         }
369         (*env)->FatalError(env, "A call to CreationError.ordinal() from rust returned an invalid value.");
370         abort(); // Unreachable, but will let the compiler know we don't return here
371 }
372 static jclass CreationError_class = NULL;
373 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
374 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
375 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
376 static jfieldID CreationError_LDKCreationError_InvalidAmount = NULL;
377 static jfieldID CreationError_LDKCreationError_MissingRouteHints = NULL;
378 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
379         CreationError_class = (*env)->NewGlobalRef(env, clz);
380         CHECK(CreationError_class != NULL);
381         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
382         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
383         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
384         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
385         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
386         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
387         CreationError_LDKCreationError_InvalidAmount = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_InvalidAmount", "Lorg/ldk/enums/CreationError;");
388         CHECK(CreationError_LDKCreationError_InvalidAmount != NULL);
389         CreationError_LDKCreationError_MissingRouteHints = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_MissingRouteHints", "Lorg/ldk/enums/CreationError;");
390         CHECK(CreationError_LDKCreationError_MissingRouteHints != NULL);
391 }
392 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
393         switch (val) {
394                 case LDKCreationError_DescriptionTooLong:
395                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
396                 case LDKCreationError_RouteTooLong:
397                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
398                 case LDKCreationError_TimestampOutOfBounds:
399                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
400                 case LDKCreationError_InvalidAmount:
401                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_InvalidAmount);
402                 case LDKCreationError_MissingRouteHints:
403                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_MissingRouteHints);
404                 default: abort();
405         }
406 }
407
408 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
409         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
410         if (UNLIKELY((*env)->ExceptionCheck(env))) {
411                 (*env)->ExceptionDescribe(env);
412                 (*env)->FatalError(env, "A call to Currency.ordinal() from rust threw an exception.");
413         }
414         switch (ord) {
415                 case 0: return LDKCurrency_Bitcoin;
416                 case 1: return LDKCurrency_BitcoinTestnet;
417                 case 2: return LDKCurrency_Regtest;
418                 case 3: return LDKCurrency_Simnet;
419                 case 4: return LDKCurrency_Signet;
420         }
421         (*env)->FatalError(env, "A call to Currency.ordinal() from rust returned an invalid value.");
422         abort(); // Unreachable, but will let the compiler know we don't return here
423 }
424 static jclass Currency_class = NULL;
425 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
426 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
427 static jfieldID Currency_LDKCurrency_Regtest = NULL;
428 static jfieldID Currency_LDKCurrency_Simnet = NULL;
429 static jfieldID Currency_LDKCurrency_Signet = NULL;
430 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
431         Currency_class = (*env)->NewGlobalRef(env, clz);
432         CHECK(Currency_class != NULL);
433         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
434         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
435         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
436         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
437         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
438         CHECK(Currency_LDKCurrency_Regtest != NULL);
439         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
440         CHECK(Currency_LDKCurrency_Simnet != NULL);
441         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
442         CHECK(Currency_LDKCurrency_Signet != NULL);
443 }
444 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
445         switch (val) {
446                 case LDKCurrency_Bitcoin:
447                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
448                 case LDKCurrency_BitcoinTestnet:
449                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
450                 case LDKCurrency_Regtest:
451                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
452                 case LDKCurrency_Simnet:
453                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
454                 case LDKCurrency_Signet:
455                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
456                 default: abort();
457         }
458 }
459
460 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
461         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
462         if (UNLIKELY((*env)->ExceptionCheck(env))) {
463                 (*env)->ExceptionDescribe(env);
464                 (*env)->FatalError(env, "A call to IOError.ordinal() from rust threw an exception.");
465         }
466         switch (ord) {
467                 case 0: return LDKIOError_NotFound;
468                 case 1: return LDKIOError_PermissionDenied;
469                 case 2: return LDKIOError_ConnectionRefused;
470                 case 3: return LDKIOError_ConnectionReset;
471                 case 4: return LDKIOError_ConnectionAborted;
472                 case 5: return LDKIOError_NotConnected;
473                 case 6: return LDKIOError_AddrInUse;
474                 case 7: return LDKIOError_AddrNotAvailable;
475                 case 8: return LDKIOError_BrokenPipe;
476                 case 9: return LDKIOError_AlreadyExists;
477                 case 10: return LDKIOError_WouldBlock;
478                 case 11: return LDKIOError_InvalidInput;
479                 case 12: return LDKIOError_InvalidData;
480                 case 13: return LDKIOError_TimedOut;
481                 case 14: return LDKIOError_WriteZero;
482                 case 15: return LDKIOError_Interrupted;
483                 case 16: return LDKIOError_Other;
484                 case 17: return LDKIOError_UnexpectedEof;
485         }
486         (*env)->FatalError(env, "A call to IOError.ordinal() from rust returned an invalid value.");
487         abort(); // Unreachable, but will let the compiler know we don't return here
488 }
489 static jclass IOError_class = NULL;
490 static jfieldID IOError_LDKIOError_NotFound = NULL;
491 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
492 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
493 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
494 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
495 static jfieldID IOError_LDKIOError_NotConnected = NULL;
496 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
497 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
498 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
499 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
500 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
501 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
502 static jfieldID IOError_LDKIOError_InvalidData = NULL;
503 static jfieldID IOError_LDKIOError_TimedOut = NULL;
504 static jfieldID IOError_LDKIOError_WriteZero = NULL;
505 static jfieldID IOError_LDKIOError_Interrupted = NULL;
506 static jfieldID IOError_LDKIOError_Other = NULL;
507 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
508 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
509         IOError_class = (*env)->NewGlobalRef(env, clz);
510         CHECK(IOError_class != NULL);
511         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
512         CHECK(IOError_LDKIOError_NotFound != NULL);
513         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
514         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
515         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
516         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
517         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
518         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
519         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
520         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
521         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
522         CHECK(IOError_LDKIOError_NotConnected != NULL);
523         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
524         CHECK(IOError_LDKIOError_AddrInUse != NULL);
525         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
526         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
527         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
528         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
529         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
530         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
531         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
532         CHECK(IOError_LDKIOError_WouldBlock != NULL);
533         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
534         CHECK(IOError_LDKIOError_InvalidInput != NULL);
535         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
536         CHECK(IOError_LDKIOError_InvalidData != NULL);
537         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
538         CHECK(IOError_LDKIOError_TimedOut != NULL);
539         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
540         CHECK(IOError_LDKIOError_WriteZero != NULL);
541         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
542         CHECK(IOError_LDKIOError_Interrupted != NULL);
543         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
544         CHECK(IOError_LDKIOError_Other != NULL);
545         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
546         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
547 }
548 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
549         switch (val) {
550                 case LDKIOError_NotFound:
551                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
552                 case LDKIOError_PermissionDenied:
553                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
554                 case LDKIOError_ConnectionRefused:
555                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
556                 case LDKIOError_ConnectionReset:
557                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
558                 case LDKIOError_ConnectionAborted:
559                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
560                 case LDKIOError_NotConnected:
561                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
562                 case LDKIOError_AddrInUse:
563                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
564                 case LDKIOError_AddrNotAvailable:
565                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
566                 case LDKIOError_BrokenPipe:
567                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
568                 case LDKIOError_AlreadyExists:
569                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
570                 case LDKIOError_WouldBlock:
571                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
572                 case LDKIOError_InvalidInput:
573                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
574                 case LDKIOError_InvalidData:
575                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
576                 case LDKIOError_TimedOut:
577                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
578                 case LDKIOError_WriteZero:
579                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
580                 case LDKIOError_Interrupted:
581                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
582                 case LDKIOError_Other:
583                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
584                 case LDKIOError_UnexpectedEof:
585                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
586                 default: abort();
587         }
588 }
589
590 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
591         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
592         if (UNLIKELY((*env)->ExceptionCheck(env))) {
593                 (*env)->ExceptionDescribe(env);
594                 (*env)->FatalError(env, "A call to Level.ordinal() from rust threw an exception.");
595         }
596         switch (ord) {
597                 case 0: return LDKLevel_Gossip;
598                 case 1: return LDKLevel_Trace;
599                 case 2: return LDKLevel_Debug;
600                 case 3: return LDKLevel_Info;
601                 case 4: return LDKLevel_Warn;
602                 case 5: return LDKLevel_Error;
603         }
604         (*env)->FatalError(env, "A call to Level.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 Level_class = NULL;
608 static jfieldID Level_LDKLevel_Gossip = NULL;
609 static jfieldID Level_LDKLevel_Trace = NULL;
610 static jfieldID Level_LDKLevel_Debug = NULL;
611 static jfieldID Level_LDKLevel_Info = NULL;
612 static jfieldID Level_LDKLevel_Warn = NULL;
613 static jfieldID Level_LDKLevel_Error = NULL;
614 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
615         Level_class = (*env)->NewGlobalRef(env, clz);
616         CHECK(Level_class != NULL);
617         Level_LDKLevel_Gossip = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Gossip", "Lorg/ldk/enums/Level;");
618         CHECK(Level_LDKLevel_Gossip != NULL);
619         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
620         CHECK(Level_LDKLevel_Trace != NULL);
621         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
622         CHECK(Level_LDKLevel_Debug != NULL);
623         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
624         CHECK(Level_LDKLevel_Info != NULL);
625         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
626         CHECK(Level_LDKLevel_Warn != NULL);
627         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
628         CHECK(Level_LDKLevel_Error != NULL);
629 }
630 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
631         switch (val) {
632                 case LDKLevel_Gossip:
633                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Gossip);
634                 case LDKLevel_Trace:
635                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
636                 case LDKLevel_Debug:
637                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
638                 case LDKLevel_Info:
639                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
640                 case LDKLevel_Warn:
641                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
642                 case LDKLevel_Error:
643                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
644                 default: abort();
645         }
646 }
647
648 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
649         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
650         if (UNLIKELY((*env)->ExceptionCheck(env))) {
651                 (*env)->ExceptionDescribe(env);
652                 (*env)->FatalError(env, "A call to Network.ordinal() from rust threw an exception.");
653         }
654         switch (ord) {
655                 case 0: return LDKNetwork_Bitcoin;
656                 case 1: return LDKNetwork_Testnet;
657                 case 2: return LDKNetwork_Regtest;
658                 case 3: return LDKNetwork_Signet;
659         }
660         (*env)->FatalError(env, "A call to Network.ordinal() from rust returned an invalid value.");
661         abort(); // Unreachable, but will let the compiler know we don't return here
662 }
663 static jclass Network_class = NULL;
664 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
665 static jfieldID Network_LDKNetwork_Testnet = NULL;
666 static jfieldID Network_LDKNetwork_Regtest = NULL;
667 static jfieldID Network_LDKNetwork_Signet = NULL;
668 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
669         Network_class = (*env)->NewGlobalRef(env, clz);
670         CHECK(Network_class != NULL);
671         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
672         CHECK(Network_LDKNetwork_Bitcoin != NULL);
673         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
674         CHECK(Network_LDKNetwork_Testnet != NULL);
675         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
676         CHECK(Network_LDKNetwork_Regtest != NULL);
677         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
678         CHECK(Network_LDKNetwork_Signet != NULL);
679 }
680 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
681         switch (val) {
682                 case LDKNetwork_Bitcoin:
683                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
684                 case LDKNetwork_Testnet:
685                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
686                 case LDKNetwork_Regtest:
687                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
688                 case LDKNetwork_Signet:
689                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
690                 default: abort();
691         }
692 }
693
694 static inline LDKRecipient LDKRecipient_from_java(JNIEnv *env, jclass clz) {
695         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
696         if (UNLIKELY((*env)->ExceptionCheck(env))) {
697                 (*env)->ExceptionDescribe(env);
698                 (*env)->FatalError(env, "A call to Recipient.ordinal() from rust threw an exception.");
699         }
700         switch (ord) {
701                 case 0: return LDKRecipient_Node;
702                 case 1: return LDKRecipient_PhantomNode;
703         }
704         (*env)->FatalError(env, "A call to Recipient.ordinal() from rust returned an invalid value.");
705         abort(); // Unreachable, but will let the compiler know we don't return here
706 }
707 static jclass Recipient_class = NULL;
708 static jfieldID Recipient_LDKRecipient_Node = NULL;
709 static jfieldID Recipient_LDKRecipient_PhantomNode = NULL;
710 JNIEXPORT void JNICALL Java_org_ldk_enums_Recipient_init (JNIEnv *env, jclass clz) {
711         Recipient_class = (*env)->NewGlobalRef(env, clz);
712         CHECK(Recipient_class != NULL);
713         Recipient_LDKRecipient_Node = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_Node", "Lorg/ldk/enums/Recipient;");
714         CHECK(Recipient_LDKRecipient_Node != NULL);
715         Recipient_LDKRecipient_PhantomNode = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_PhantomNode", "Lorg/ldk/enums/Recipient;");
716         CHECK(Recipient_LDKRecipient_PhantomNode != NULL);
717 }
718 static inline jclass LDKRecipient_to_java(JNIEnv *env, LDKRecipient val) {
719         switch (val) {
720                 case LDKRecipient_Node:
721                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_Node);
722                 case LDKRecipient_PhantomNode:
723                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_PhantomNode);
724                 default: abort();
725         }
726 }
727
728 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
729         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
730         if (UNLIKELY((*env)->ExceptionCheck(env))) {
731                 (*env)->ExceptionDescribe(env);
732                 (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust threw an exception.");
733         }
734         switch (ord) {
735                 case 0: return LDKSecp256k1Error_IncorrectSignature;
736                 case 1: return LDKSecp256k1Error_InvalidMessage;
737                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
738                 case 3: return LDKSecp256k1Error_InvalidSignature;
739                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
740                 case 5: return LDKSecp256k1Error_InvalidSharedSecret;
741                 case 6: return LDKSecp256k1Error_InvalidRecoveryId;
742                 case 7: return LDKSecp256k1Error_InvalidTweak;
743                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
744                 case 9: return LDKSecp256k1Error_InvalidPublicKeySum;
745                 case 10: return LDKSecp256k1Error_InvalidParityValue;
746         }
747         (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust returned an invalid value.");
748         abort(); // Unreachable, but will let the compiler know we don't return here
749 }
750 static jclass Secp256k1Error_class = NULL;
751 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
752 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
753 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
754 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
755 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
756 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = NULL;
757 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
758 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
759 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
760 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = NULL;
761 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = NULL;
762 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
763         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
764         CHECK(Secp256k1Error_class != NULL);
765         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
766         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
767         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
768         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
769         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
770         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
771         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
772         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
773         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
774         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
775         Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSharedSecret", "Lorg/ldk/enums/Secp256k1Error;");
776         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret != NULL);
777         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
778         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
779         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
780         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
781         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
782         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
783         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKeySum", "Lorg/ldk/enums/Secp256k1Error;");
784         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum != NULL);
785         Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidParityValue", "Lorg/ldk/enums/Secp256k1Error;");
786         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidParityValue != NULL);
787 }
788 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
789         switch (val) {
790                 case LDKSecp256k1Error_IncorrectSignature:
791                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
792                 case LDKSecp256k1Error_InvalidMessage:
793                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
794                 case LDKSecp256k1Error_InvalidPublicKey:
795                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
796                 case LDKSecp256k1Error_InvalidSignature:
797                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
798                 case LDKSecp256k1Error_InvalidSecretKey:
799                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
800                 case LDKSecp256k1Error_InvalidSharedSecret:
801                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret);
802                 case LDKSecp256k1Error_InvalidRecoveryId:
803                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
804                 case LDKSecp256k1Error_InvalidTweak:
805                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
806                 case LDKSecp256k1Error_NotEnoughMemory:
807                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
808                 case LDKSecp256k1Error_InvalidPublicKeySum:
809                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum);
810                 case LDKSecp256k1Error_InvalidParityValue:
811                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidParityValue);
812                 default: abort();
813         }
814 }
815
816 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
817         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
818         if (UNLIKELY((*env)->ExceptionCheck(env))) {
819                 (*env)->ExceptionDescribe(env);
820                 (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust threw an exception.");
821         }
822         switch (ord) {
823                 case 0: return LDKSemanticError_NoPaymentHash;
824                 case 1: return LDKSemanticError_MultiplePaymentHashes;
825                 case 2: return LDKSemanticError_NoDescription;
826                 case 3: return LDKSemanticError_MultipleDescriptions;
827                 case 4: return LDKSemanticError_NoPaymentSecret;
828                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
829                 case 6: return LDKSemanticError_InvalidFeatures;
830                 case 7: return LDKSemanticError_InvalidRecoveryId;
831                 case 8: return LDKSemanticError_InvalidSignature;
832                 case 9: return LDKSemanticError_ImpreciseAmount;
833         }
834         (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust returned an invalid value.");
835         abort(); // Unreachable, but will let the compiler know we don't return here
836 }
837 static jclass SemanticError_class = NULL;
838 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
839 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
840 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
841 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
842 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
843 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
844 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
845 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
846 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
847 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
848 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
849         SemanticError_class = (*env)->NewGlobalRef(env, clz);
850         CHECK(SemanticError_class != NULL);
851         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
852         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
853         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
854         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
855         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
856         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
857         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
858         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
859         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
860         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
861         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
862         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
863         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
864         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
865         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
866         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
867         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
868         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
869         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
870         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
871 }
872 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
873         switch (val) {
874                 case LDKSemanticError_NoPaymentHash:
875                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
876                 case LDKSemanticError_MultiplePaymentHashes:
877                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
878                 case LDKSemanticError_NoDescription:
879                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
880                 case LDKSemanticError_MultipleDescriptions:
881                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
882                 case LDKSemanticError_NoPaymentSecret:
883                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
884                 case LDKSemanticError_MultiplePaymentSecrets:
885                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
886                 case LDKSemanticError_InvalidFeatures:
887                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
888                 case LDKSemanticError_InvalidRecoveryId:
889                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
890                 case LDKSemanticError_InvalidSignature:
891                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
892                 case LDKSemanticError_ImpreciseAmount:
893                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
894                 default: abort();
895         }
896 }
897
898 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
899         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
900         if (UNLIKELY((*env)->ExceptionCheck(env))) {
901                 (*env)->ExceptionDescribe(env);
902                 (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust threw an exception.");
903         }
904         switch (ord) {
905                 case 0: return LDKSiPrefix_Milli;
906                 case 1: return LDKSiPrefix_Micro;
907                 case 2: return LDKSiPrefix_Nano;
908                 case 3: return LDKSiPrefix_Pico;
909         }
910         (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust returned an invalid value.");
911         abort(); // Unreachable, but will let the compiler know we don't return here
912 }
913 static jclass SiPrefix_class = NULL;
914 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
915 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
916 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
917 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
918 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
919         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
920         CHECK(SiPrefix_class != NULL);
921         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
922         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
923         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
924         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
925         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
926         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
927         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
928         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
929 }
930 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
931         switch (val) {
932                 case LDKSiPrefix_Milli:
933                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
934                 case LDKSiPrefix_Micro:
935                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
936                 case LDKSiPrefix_Nano:
937                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
938                 case LDKSiPrefix_Pico:
939                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
940                 default: abort();
941         }
942 }
943
944 struct LDKThirtyTwoBytes BigEndianScalar_get_bytes (struct LDKBigEndianScalar* thing) {
945         LDKThirtyTwoBytes ret = { .data = *thing->big_endian_bytes };
946         return ret;
947 }
948 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1get_1bytes(JNIEnv *env, jclass clz, int64_t thing) {
949         LDKBigEndianScalar* thing_conv = (LDKBigEndianScalar*)untag_ptr(thing);
950         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
951         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BigEndianScalar_get_bytes(thing_conv).data);
952         return ret_arr;
953 }
954
955 static void BigEndianScalar_free (struct LDKBigEndianScalar thing) {}
956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1free(JNIEnv *env, jclass clz, int64_t thing) {
957         if (!ptr_is_owned(thing)) return;
958         void* thing_ptr = untag_ptr(thing);
959         CHECK_ACCESS(thing_ptr);
960         LDKBigEndianScalar thing_conv = *(LDKBigEndianScalar*)(thing_ptr);
961         FREE(untag_ptr(thing));
962         BigEndianScalar_free(thing_conv);
963 }
964
965 static jclass LDKBech32Error_MissingSeparator_class = NULL;
966 static jmethodID LDKBech32Error_MissingSeparator_meth = NULL;
967 static jclass LDKBech32Error_InvalidChecksum_class = NULL;
968 static jmethodID LDKBech32Error_InvalidChecksum_meth = NULL;
969 static jclass LDKBech32Error_InvalidLength_class = NULL;
970 static jmethodID LDKBech32Error_InvalidLength_meth = NULL;
971 static jclass LDKBech32Error_InvalidChar_class = NULL;
972 static jmethodID LDKBech32Error_InvalidChar_meth = NULL;
973 static jclass LDKBech32Error_InvalidData_class = NULL;
974 static jmethodID LDKBech32Error_InvalidData_meth = NULL;
975 static jclass LDKBech32Error_InvalidPadding_class = NULL;
976 static jmethodID LDKBech32Error_InvalidPadding_meth = NULL;
977 static jclass LDKBech32Error_MixedCase_class = NULL;
978 static jmethodID LDKBech32Error_MixedCase_meth = NULL;
979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBech32Error_init (JNIEnv *env, jclass clz) {
980         LDKBech32Error_MissingSeparator_class =
981                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MissingSeparator"));
982         CHECK(LDKBech32Error_MissingSeparator_class != NULL);
983         LDKBech32Error_MissingSeparator_meth = (*env)->GetMethodID(env, LDKBech32Error_MissingSeparator_class, "<init>", "()V");
984         CHECK(LDKBech32Error_MissingSeparator_meth != NULL);
985         LDKBech32Error_InvalidChecksum_class =
986                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChecksum"));
987         CHECK(LDKBech32Error_InvalidChecksum_class != NULL);
988         LDKBech32Error_InvalidChecksum_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChecksum_class, "<init>", "()V");
989         CHECK(LDKBech32Error_InvalidChecksum_meth != NULL);
990         LDKBech32Error_InvalidLength_class =
991                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidLength"));
992         CHECK(LDKBech32Error_InvalidLength_class != NULL);
993         LDKBech32Error_InvalidLength_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidLength_class, "<init>", "()V");
994         CHECK(LDKBech32Error_InvalidLength_meth != NULL);
995         LDKBech32Error_InvalidChar_class =
996                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChar"));
997         CHECK(LDKBech32Error_InvalidChar_class != NULL);
998         LDKBech32Error_InvalidChar_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChar_class, "<init>", "(I)V");
999         CHECK(LDKBech32Error_InvalidChar_meth != NULL);
1000         LDKBech32Error_InvalidData_class =
1001                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidData"));
1002         CHECK(LDKBech32Error_InvalidData_class != NULL);
1003         LDKBech32Error_InvalidData_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidData_class, "<init>", "(B)V");
1004         CHECK(LDKBech32Error_InvalidData_meth != NULL);
1005         LDKBech32Error_InvalidPadding_class =
1006                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidPadding"));
1007         CHECK(LDKBech32Error_InvalidPadding_class != NULL);
1008         LDKBech32Error_InvalidPadding_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidPadding_class, "<init>", "()V");
1009         CHECK(LDKBech32Error_InvalidPadding_meth != NULL);
1010         LDKBech32Error_MixedCase_class =
1011                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MixedCase"));
1012         CHECK(LDKBech32Error_MixedCase_class != NULL);
1013         LDKBech32Error_MixedCase_meth = (*env)->GetMethodID(env, LDKBech32Error_MixedCase_class, "<init>", "()V");
1014         CHECK(LDKBech32Error_MixedCase_meth != NULL);
1015 }
1016 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBech32Error_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1017         LDKBech32Error *obj = (LDKBech32Error*)untag_ptr(ptr);
1018         switch(obj->tag) {
1019                 case LDKBech32Error_MissingSeparator: {
1020                         return (*env)->NewObject(env, LDKBech32Error_MissingSeparator_class, LDKBech32Error_MissingSeparator_meth);
1021                 }
1022                 case LDKBech32Error_InvalidChecksum: {
1023                         return (*env)->NewObject(env, LDKBech32Error_InvalidChecksum_class, LDKBech32Error_InvalidChecksum_meth);
1024                 }
1025                 case LDKBech32Error_InvalidLength: {
1026                         return (*env)->NewObject(env, LDKBech32Error_InvalidLength_class, LDKBech32Error_InvalidLength_meth);
1027                 }
1028                 case LDKBech32Error_InvalidChar: {
1029                         int32_t invalid_char_conv = obj->invalid_char;
1030                         return (*env)->NewObject(env, LDKBech32Error_InvalidChar_class, LDKBech32Error_InvalidChar_meth, invalid_char_conv);
1031                 }
1032                 case LDKBech32Error_InvalidData: {
1033                         int8_t invalid_data_conv = obj->invalid_data;
1034                         return (*env)->NewObject(env, LDKBech32Error_InvalidData_class, LDKBech32Error_InvalidData_meth, invalid_data_conv);
1035                 }
1036                 case LDKBech32Error_InvalidPadding: {
1037                         return (*env)->NewObject(env, LDKBech32Error_InvalidPadding_class, LDKBech32Error_InvalidPadding_meth);
1038                 }
1039                 case LDKBech32Error_MixedCase: {
1040                         return (*env)->NewObject(env, LDKBech32Error_MixedCase_class, LDKBech32Error_MixedCase_meth);
1041                 }
1042                 default: abort();
1043         }
1044 }
1045 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
1046         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
1047         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
1048         return ret;
1049 }
1050 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) {
1051         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
1052         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
1053         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1054         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1055         CVec_u8Z_free(ret_var);
1056         return ret_arr;
1057 }
1058
1059 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) {
1060         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
1061         int64_t ret_conv = TxOut_get_value(thing_conv);
1062         return ret_conv;
1063 }
1064
1065 static inline struct LDKBlindedRoute CResult_BlindedRouteNoneZ_get_ok(LDKCResult_BlindedRouteNoneZ *NONNULL_PTR owner){
1066         LDKBlindedRoute ret = *owner->contents.result;
1067         ret.is_owned = false;
1068         return ret;
1069 }
1070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1071         LDKCResult_BlindedRouteNoneZ* owner_conv = (LDKCResult_BlindedRouteNoneZ*)untag_ptr(owner);
1072         LDKBlindedRoute ret_var = CResult_BlindedRouteNoneZ_get_ok(owner_conv);
1073         int64_t ret_ref = 0;
1074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1075         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1076         return ret_ref;
1077 }
1078
1079 static inline void CResult_BlindedRouteNoneZ_get_err(LDKCResult_BlindedRouteNoneZ *NONNULL_PTR owner){
1080 CHECK(!owner->result_ok);
1081         return *owner->contents.err;
1082 }
1083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1084         LDKCResult_BlindedRouteNoneZ* owner_conv = (LDKCResult_BlindedRouteNoneZ*)untag_ptr(owner);
1085         CResult_BlindedRouteNoneZ_get_err(owner_conv);
1086 }
1087
1088 static inline struct LDKBlindedRoute CResult_BlindedRouteDecodeErrorZ_get_ok(LDKCResult_BlindedRouteDecodeErrorZ *NONNULL_PTR owner){
1089         LDKBlindedRoute ret = *owner->contents.result;
1090         ret.is_owned = false;
1091         return ret;
1092 }
1093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1094         LDKCResult_BlindedRouteDecodeErrorZ* owner_conv = (LDKCResult_BlindedRouteDecodeErrorZ*)untag_ptr(owner);
1095         LDKBlindedRoute ret_var = CResult_BlindedRouteDecodeErrorZ_get_ok(owner_conv);
1096         int64_t ret_ref = 0;
1097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1098         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1099         return ret_ref;
1100 }
1101
1102 static inline struct LDKDecodeError CResult_BlindedRouteDecodeErrorZ_get_err(LDKCResult_BlindedRouteDecodeErrorZ *NONNULL_PTR owner){
1103         LDKDecodeError ret = *owner->contents.err;
1104         ret.is_owned = false;
1105         return ret;
1106 }
1107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1108         LDKCResult_BlindedRouteDecodeErrorZ* owner_conv = (LDKCResult_BlindedRouteDecodeErrorZ*)untag_ptr(owner);
1109         LDKDecodeError ret_var = CResult_BlindedRouteDecodeErrorZ_get_err(owner_conv);
1110         int64_t ret_ref = 0;
1111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1112         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1113         return ret_ref;
1114 }
1115
1116 static inline struct LDKBlindedHop CResult_BlindedHopDecodeErrorZ_get_ok(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR owner){
1117         LDKBlindedHop ret = *owner->contents.result;
1118         ret.is_owned = false;
1119         return ret;
1120 }
1121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1122         LDKCResult_BlindedHopDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(owner);
1123         LDKBlindedHop ret_var = CResult_BlindedHopDecodeErrorZ_get_ok(owner_conv);
1124         int64_t ret_ref = 0;
1125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1126         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1127         return ret_ref;
1128 }
1129
1130 static inline struct LDKDecodeError CResult_BlindedHopDecodeErrorZ_get_err(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR owner){
1131         LDKDecodeError ret = *owner->contents.err;
1132         ret.is_owned = false;
1133         return ret;
1134 }
1135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1136         LDKCResult_BlindedHopDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(owner);
1137         LDKDecodeError ret_var = CResult_BlindedHopDecodeErrorZ_get_err(owner_conv);
1138         int64_t ret_ref = 0;
1139         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1140         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1141         return ret_ref;
1142 }
1143
1144 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1145 CHECK(owner->result_ok);
1146         return *owner->contents.result;
1147 }
1148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1149         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
1150         CResult_NoneNoneZ_get_ok(owner_conv);
1151 }
1152
1153 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1154 CHECK(!owner->result_ok);
1155         return *owner->contents.err;
1156 }
1157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1158         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
1159         CResult_NoneNoneZ_get_err(owner_conv);
1160 }
1161
1162 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1163         LDKCounterpartyCommitmentSecrets ret = *owner->contents.result;
1164         ret.is_owned = false;
1165         return ret;
1166 }
1167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1168         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
1169         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
1170         int64_t ret_ref = 0;
1171         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1172         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1173         return ret_ref;
1174 }
1175
1176 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1177         LDKDecodeError ret = *owner->contents.err;
1178         ret.is_owned = false;
1179         return ret;
1180 }
1181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1182         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
1183         LDKDecodeError ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
1184         int64_t ret_ref = 0;
1185         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1186         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1187         return ret_ref;
1188 }
1189
1190 static inline struct LDKSecretKey CResult_SecretKeyErrorZ_get_ok(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1191 CHECK(owner->result_ok);
1192         return *owner->contents.result;
1193 }
1194 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1195         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(owner);
1196         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
1197         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyErrorZ_get_ok(owner_conv).bytes);
1198         return ret_arr;
1199 }
1200
1201 static inline enum LDKSecp256k1Error CResult_SecretKeyErrorZ_get_err(LDKCResult_SecretKeyErrorZ *NONNULL_PTR owner){
1202 CHECK(!owner->result_ok);
1203         return *owner->contents.err;
1204 }
1205 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1206         LDKCResult_SecretKeyErrorZ* owner_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(owner);
1207         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_SecretKeyErrorZ_get_err(owner_conv));
1208         return ret_conv;
1209 }
1210
1211 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1212 CHECK(owner->result_ok);
1213         return *owner->contents.result;
1214 }
1215 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1216         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(owner);
1217         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
1218         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form);
1219         return ret_arr;
1220 }
1221
1222 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
1223 CHECK(!owner->result_ok);
1224         return *owner->contents.err;
1225 }
1226 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1227         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(owner);
1228         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PublicKeyErrorZ_get_err(owner_conv));
1229         return ret_conv;
1230 }
1231
1232 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1233         LDKTxCreationKeys ret = *owner->contents.result;
1234         ret.is_owned = false;
1235         return ret;
1236 }
1237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1238         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
1239         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
1240         int64_t ret_ref = 0;
1241         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1242         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1243         return ret_ref;
1244 }
1245
1246 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1247         LDKDecodeError ret = *owner->contents.err;
1248         ret.is_owned = false;
1249         return ret;
1250 }
1251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1252         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
1253         LDKDecodeError ret_var = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
1254         int64_t ret_ref = 0;
1255         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1256         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1257         return ret_ref;
1258 }
1259
1260 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1261         LDKChannelPublicKeys ret = *owner->contents.result;
1262         ret.is_owned = false;
1263         return ret;
1264 }
1265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1266         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
1267         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
1268         int64_t ret_ref = 0;
1269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1270         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1271         return ret_ref;
1272 }
1273
1274 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1275         LDKDecodeError ret = *owner->contents.err;
1276         ret.is_owned = false;
1277         return ret;
1278 }
1279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1280         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
1281         LDKDecodeError ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
1282         int64_t ret_ref = 0;
1283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1284         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1285         return ret_ref;
1286 }
1287
1288 static inline struct LDKTxCreationKeys CResult_TxCreationKeysErrorZ_get_ok(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1289         LDKTxCreationKeys ret = *owner->contents.result;
1290         ret.is_owned = false;
1291         return ret;
1292 }
1293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1294         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(owner);
1295         LDKTxCreationKeys ret_var = CResult_TxCreationKeysErrorZ_get_ok(owner_conv);
1296         int64_t ret_ref = 0;
1297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1298         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1299         return ret_ref;
1300 }
1301
1302 static inline enum LDKSecp256k1Error CResult_TxCreationKeysErrorZ_get_err(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR owner){
1303 CHECK(!owner->result_ok);
1304         return *owner->contents.err;
1305 }
1306 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1307         LDKCResult_TxCreationKeysErrorZ* owner_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(owner);
1308         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_TxCreationKeysErrorZ_get_err(owner_conv));
1309         return ret_conv;
1310 }
1311
1312 static jclass LDKCOption_u32Z_Some_class = NULL;
1313 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
1314 static jclass LDKCOption_u32Z_None_class = NULL;
1315 static jmethodID LDKCOption_u32Z_None_meth = NULL;
1316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
1317         LDKCOption_u32Z_Some_class =
1318                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$Some"));
1319         CHECK(LDKCOption_u32Z_Some_class != NULL);
1320         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
1321         CHECK(LDKCOption_u32Z_Some_meth != NULL);
1322         LDKCOption_u32Z_None_class =
1323                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$None"));
1324         CHECK(LDKCOption_u32Z_None_class != NULL);
1325         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
1326         CHECK(LDKCOption_u32Z_None_meth != NULL);
1327 }
1328 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1329         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)untag_ptr(ptr);
1330         switch(obj->tag) {
1331                 case LDKCOption_u32Z_Some: {
1332                         int32_t some_conv = obj->some;
1333                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, some_conv);
1334                 }
1335                 case LDKCOption_u32Z_None: {
1336                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
1337                 }
1338                 default: abort();
1339         }
1340 }
1341 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1342         LDKHTLCOutputInCommitment ret = *owner->contents.result;
1343         ret.is_owned = false;
1344         return ret;
1345 }
1346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1347         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
1348         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
1349         int64_t ret_ref = 0;
1350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1351         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1352         return ret_ref;
1353 }
1354
1355 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1356         LDKDecodeError ret = *owner->contents.err;
1357         ret.is_owned = false;
1358         return ret;
1359 }
1360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1361         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
1362         LDKDecodeError ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
1363         int64_t ret_ref = 0;
1364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1365         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1366         return ret_ref;
1367 }
1368
1369 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1370         LDKCounterpartyChannelTransactionParameters ret = *owner->contents.result;
1371         ret.is_owned = false;
1372         return ret;
1373 }
1374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1375         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1376         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1377         int64_t ret_ref = 0;
1378         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1379         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1380         return ret_ref;
1381 }
1382
1383 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1384         LDKDecodeError ret = *owner->contents.err;
1385         ret.is_owned = false;
1386         return ret;
1387 }
1388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1389         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1390         LDKDecodeError ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1391         int64_t ret_ref = 0;
1392         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1393         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1394         return ret_ref;
1395 }
1396
1397 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1398         LDKChannelTransactionParameters ret = *owner->contents.result;
1399         ret.is_owned = false;
1400         return ret;
1401 }
1402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1403         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1404         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1405         int64_t ret_ref = 0;
1406         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1407         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1408         return ret_ref;
1409 }
1410
1411 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1412         LDKDecodeError ret = *owner->contents.err;
1413         ret.is_owned = false;
1414         return ret;
1415 }
1416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1417         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1418         LDKDecodeError ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1419         int64_t ret_ref = 0;
1420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1421         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1422         return ret_ref;
1423 }
1424
1425 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1426         LDKHolderCommitmentTransaction ret = *owner->contents.result;
1427         ret.is_owned = false;
1428         return ret;
1429 }
1430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1431         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1432         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1433         int64_t ret_ref = 0;
1434         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1435         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1436         return ret_ref;
1437 }
1438
1439 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1440         LDKDecodeError ret = *owner->contents.err;
1441         ret.is_owned = false;
1442         return ret;
1443 }
1444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1445         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1446         LDKDecodeError ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1447         int64_t ret_ref = 0;
1448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1449         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1450         return ret_ref;
1451 }
1452
1453 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1454         LDKBuiltCommitmentTransaction ret = *owner->contents.result;
1455         ret.is_owned = false;
1456         return ret;
1457 }
1458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1459         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1460         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1461         int64_t ret_ref = 0;
1462         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1463         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1464         return ret_ref;
1465 }
1466
1467 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1468         LDKDecodeError ret = *owner->contents.err;
1469         ret.is_owned = false;
1470         return ret;
1471 }
1472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1473         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1474         LDKDecodeError ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1475         int64_t ret_ref = 0;
1476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1477         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1478         return ret_ref;
1479 }
1480
1481 static inline struct LDKTrustedClosingTransaction CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1482         LDKTrustedClosingTransaction ret = *owner->contents.result;
1483         ret.is_owned = false;
1484         return ret;
1485 }
1486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1487         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
1488         LDKTrustedClosingTransaction ret_var = CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
1489         int64_t ret_ref = 0;
1490         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1491         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1492         return ret_ref;
1493 }
1494
1495 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1496 CHECK(!owner->result_ok);
1497         return *owner->contents.err;
1498 }
1499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1500         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
1501         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
1502 }
1503
1504 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1505         LDKCommitmentTransaction ret = *owner->contents.result;
1506         ret.is_owned = false;
1507         return ret;
1508 }
1509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1510         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1511         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1512         int64_t ret_ref = 0;
1513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1514         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1515         return ret_ref;
1516 }
1517
1518 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1519         LDKDecodeError ret = *owner->contents.err;
1520         ret.is_owned = false;
1521         return ret;
1522 }
1523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1524         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1525         LDKDecodeError ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1526         int64_t ret_ref = 0;
1527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1528         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1529         return ret_ref;
1530 }
1531
1532 static inline struct LDKTrustedCommitmentTransaction CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1533         LDKTrustedCommitmentTransaction ret = *owner->contents.result;
1534         ret.is_owned = false;
1535         return ret;
1536 }
1537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1538         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
1539         LDKTrustedCommitmentTransaction ret_var = CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
1540         int64_t ret_ref = 0;
1541         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1542         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1543         return ret_ref;
1544 }
1545
1546 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1547 CHECK(!owner->result_ok);
1548         return *owner->contents.err;
1549 }
1550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1551         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
1552         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
1553 }
1554
1555 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1556 CHECK(owner->result_ok);
1557         return *owner->contents.result;
1558 }
1559 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1560         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(owner);
1561         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
1562         jobjectArray ret_arr = NULL;
1563         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
1564         ;
1565         for (size_t i = 0; i < ret_var.datalen; i++) {
1566                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
1567                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
1568                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
1569         }
1570         
1571         return ret_arr;
1572 }
1573
1574 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1575 CHECK(!owner->result_ok);
1576         return *owner->contents.err;
1577 }
1578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1579         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(owner);
1580         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
1581 }
1582
1583 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1584         LDKShutdownScript ret = *owner->contents.result;
1585         ret.is_owned = false;
1586         return ret;
1587 }
1588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1589         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
1590         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
1591         int64_t ret_ref = 0;
1592         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1593         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1594         return ret_ref;
1595 }
1596
1597 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1598         LDKDecodeError ret = *owner->contents.err;
1599         ret.is_owned = false;
1600         return ret;
1601 }
1602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1603         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
1604         LDKDecodeError ret_var = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
1605         int64_t ret_ref = 0;
1606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1607         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1608         return ret_ref;
1609 }
1610
1611 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1612         LDKShutdownScript ret = *owner->contents.result;
1613         ret.is_owned = false;
1614         return ret;
1615 }
1616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1617         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
1618         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
1619         int64_t ret_ref = 0;
1620         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1621         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1622         return ret_ref;
1623 }
1624
1625 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1626         LDKInvalidShutdownScript ret = *owner->contents.err;
1627         ret.is_owned = false;
1628         return ret;
1629 }
1630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1631         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
1632         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
1633         int64_t ret_ref = 0;
1634         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1635         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1636         return ret_ref;
1637 }
1638
1639 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1640         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1641         for (size_t i = 0; i < ret.datalen; i++) {
1642                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1643         }
1644         return ret;
1645 }
1646 typedef struct LDKScore_JCalls {
1647         atomic_size_t refcnt;
1648         JavaVM *vm;
1649         jweak o;
1650         jmethodID channel_penalty_msat_meth;
1651         jmethodID payment_path_failed_meth;
1652         jmethodID payment_path_successful_meth;
1653         jmethodID probe_failed_meth;
1654         jmethodID probe_successful_meth;
1655         jmethodID write_meth;
1656 } LDKScore_JCalls;
1657 static void LDKScore_JCalls_free(void* this_arg) {
1658         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1659         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1660                 JNIEnv *env;
1661                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1662                 if (get_jenv_res == JNI_EDETACHED) {
1663                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1664                 } else {
1665                         DO_ASSERT(get_jenv_res == JNI_OK);
1666                 }
1667                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1668                 if (get_jenv_res == JNI_EDETACHED) {
1669                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1670                 }
1671                 FREE(j_calls);
1672         }
1673 }
1674 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage) {
1675         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1676         JNIEnv *env;
1677         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1678         if (get_jenv_res == JNI_EDETACHED) {
1679                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1680         } else {
1681                 DO_ASSERT(get_jenv_res == JNI_OK);
1682         }
1683         int64_t short_channel_id_conv = short_channel_id;
1684         LDKNodeId source_var = *source;
1685         int64_t source_ref = 0;
1686         source_var = NodeId_clone(&source_var);
1687         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
1688         source_ref = tag_ptr(source_var.inner, source_var.is_owned);
1689         LDKNodeId target_var = *target;
1690         int64_t target_ref = 0;
1691         target_var = NodeId_clone(&target_var);
1692         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
1693         target_ref = tag_ptr(target_var.inner, target_var.is_owned);
1694         LDKChannelUsage usage_var = usage;
1695         int64_t usage_ref = 0;
1696         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
1697         usage_ref = tag_ptr(usage_var.inner, usage_var.is_owned);
1698         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1699         CHECK(obj != NULL);
1700         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id_conv, source_ref, target_ref, usage_ref);
1701         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1702                 (*env)->ExceptionDescribe(env);
1703                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
1704         }
1705         if (get_jenv_res == JNI_EDETACHED) {
1706                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1707         }
1708         return ret;
1709 }
1710 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
1711         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1712         JNIEnv *env;
1713         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1714         if (get_jenv_res == JNI_EDETACHED) {
1715                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1716         } else {
1717                 DO_ASSERT(get_jenv_res == JNI_OK);
1718         }
1719         LDKCVec_RouteHopZ path_var = path;
1720         int64_tArray path_arr = NULL;
1721         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1722         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1723         for (size_t k = 0; k < path_var.datalen; k++) {
1724                 LDKRouteHop path_conv_10_var = path_var.data[k];
1725                 int64_t path_conv_10_ref = 0;
1726                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1727                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1728                 path_arr_ptr[k] = path_conv_10_ref;
1729         }
1730         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1731         FREE(path_var.data);
1732         int64_t short_channel_id_conv = short_channel_id;
1733         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1734         CHECK(obj != NULL);
1735         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id_conv);
1736         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1737                 (*env)->ExceptionDescribe(env);
1738                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
1739         }
1740         if (get_jenv_res == JNI_EDETACHED) {
1741                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1742         }
1743 }
1744 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
1745         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1746         JNIEnv *env;
1747         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1748         if (get_jenv_res == JNI_EDETACHED) {
1749                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1750         } else {
1751                 DO_ASSERT(get_jenv_res == JNI_OK);
1752         }
1753         LDKCVec_RouteHopZ path_var = path;
1754         int64_tArray path_arr = NULL;
1755         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1756         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1757         for (size_t k = 0; k < path_var.datalen; k++) {
1758                 LDKRouteHop path_conv_10_var = path_var.data[k];
1759                 int64_t path_conv_10_ref = 0;
1760                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1761                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1762                 path_arr_ptr[k] = path_conv_10_ref;
1763         }
1764         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1765         FREE(path_var.data);
1766         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1767         CHECK(obj != NULL);
1768         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_arr);
1769         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1770                 (*env)->ExceptionDescribe(env);
1771                 (*env)->FatalError(env, "A call to payment_path_successful in LDKScore from rust threw an exception.");
1772         }
1773         if (get_jenv_res == JNI_EDETACHED) {
1774                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1775         }
1776 }
1777 void probe_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
1778         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1779         JNIEnv *env;
1780         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1781         if (get_jenv_res == JNI_EDETACHED) {
1782                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1783         } else {
1784                 DO_ASSERT(get_jenv_res == JNI_OK);
1785         }
1786         LDKCVec_RouteHopZ path_var = path;
1787         int64_tArray path_arr = NULL;
1788         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1789         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1790         for (size_t k = 0; k < path_var.datalen; k++) {
1791                 LDKRouteHop path_conv_10_var = path_var.data[k];
1792                 int64_t path_conv_10_ref = 0;
1793                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1794                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1795                 path_arr_ptr[k] = path_conv_10_ref;
1796         }
1797         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1798         FREE(path_var.data);
1799         int64_t short_channel_id_conv = short_channel_id;
1800         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1801         CHECK(obj != NULL);
1802         (*env)->CallVoidMethod(env, obj, j_calls->probe_failed_meth, path_arr, short_channel_id_conv);
1803         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1804                 (*env)->ExceptionDescribe(env);
1805                 (*env)->FatalError(env, "A call to probe_failed in LDKScore from rust threw an exception.");
1806         }
1807         if (get_jenv_res == JNI_EDETACHED) {
1808                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1809         }
1810 }
1811 void probe_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
1812         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1813         JNIEnv *env;
1814         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1815         if (get_jenv_res == JNI_EDETACHED) {
1816                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1817         } else {
1818                 DO_ASSERT(get_jenv_res == JNI_OK);
1819         }
1820         LDKCVec_RouteHopZ path_var = path;
1821         int64_tArray path_arr = NULL;
1822         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1823         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1824         for (size_t k = 0; k < path_var.datalen; k++) {
1825                 LDKRouteHop path_conv_10_var = path_var.data[k];
1826                 int64_t path_conv_10_ref = 0;
1827                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1828                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1829                 path_arr_ptr[k] = path_conv_10_ref;
1830         }
1831         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1832         FREE(path_var.data);
1833         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1834         CHECK(obj != NULL);
1835         (*env)->CallVoidMethod(env, obj, j_calls->probe_successful_meth, path_arr);
1836         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1837                 (*env)->ExceptionDescribe(env);
1838                 (*env)->FatalError(env, "A call to probe_successful in LDKScore from rust threw an exception.");
1839         }
1840         if (get_jenv_res == JNI_EDETACHED) {
1841                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1842         }
1843 }
1844 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
1845         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1846         JNIEnv *env;
1847         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1848         if (get_jenv_res == JNI_EDETACHED) {
1849                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1850         } else {
1851                 DO_ASSERT(get_jenv_res == JNI_OK);
1852         }
1853         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1854         CHECK(obj != NULL);
1855         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
1856         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1857                 (*env)->ExceptionDescribe(env);
1858                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
1859         }
1860         LDKCVec_u8Z ret_ref;
1861         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
1862         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
1863         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
1864         if (get_jenv_res == JNI_EDETACHED) {
1865                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1866         }
1867         return ret_ref;
1868 }
1869 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
1870         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
1871         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1872 }
1873 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
1874         jclass c = (*env)->GetObjectClass(env, o);
1875         CHECK(c != NULL);
1876         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
1877         atomic_init(&calls->refcnt, 1);
1878         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1879         calls->o = (*env)->NewWeakGlobalRef(env, o);
1880         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJ)J");
1881         CHECK(calls->channel_penalty_msat_meth != NULL);
1882         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
1883         CHECK(calls->payment_path_failed_meth != NULL);
1884         calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "([J)V");
1885         CHECK(calls->payment_path_successful_meth != NULL);
1886         calls->probe_failed_meth = (*env)->GetMethodID(env, c, "probe_failed", "([JJ)V");
1887         CHECK(calls->probe_failed_meth != NULL);
1888         calls->probe_successful_meth = (*env)->GetMethodID(env, c, "probe_successful", "([J)V");
1889         CHECK(calls->probe_successful_meth != NULL);
1890         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
1891         CHECK(calls->write_meth != NULL);
1892
1893         LDKScore ret = {
1894                 .this_arg = (void*) calls,
1895                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
1896                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
1897                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
1898                 .probe_failed = probe_failed_LDKScore_jcall,
1899                 .probe_successful = probe_successful_LDKScore_jcall,
1900                 .write = write_LDKScore_jcall,
1901                 .free = LDKScore_JCalls_free,
1902         };
1903         return ret;
1904 }
1905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
1906         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
1907         *res_ptr = LDKScore_init(env, clz, o);
1908         return tag_ptr(res_ptr, true);
1909 }
1910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Score_1channel_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, int64_t source, int64_t target, int64_t usage) {
1911         void* this_arg_ptr = untag_ptr(this_arg);
1912         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1913         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
1914         LDKNodeId source_conv;
1915         source_conv.inner = untag_ptr(source);
1916         source_conv.is_owned = ptr_is_owned(source);
1917         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
1918         source_conv.is_owned = false;
1919         LDKNodeId target_conv;
1920         target_conv.inner = untag_ptr(target);
1921         target_conv.is_owned = ptr_is_owned(target);
1922         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
1923         target_conv.is_owned = false;
1924         LDKChannelUsage usage_conv;
1925         usage_conv.inner = untag_ptr(usage);
1926         usage_conv.is_owned = ptr_is_owned(usage);
1927         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
1928         usage_conv = ChannelUsage_clone(&usage_conv);
1929         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv);
1930         return ret_conv;
1931 }
1932
1933 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) {
1934         void* this_arg_ptr = untag_ptr(this_arg);
1935         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1936         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
1937         LDKCVec_RouteHopZ path_constr;
1938         path_constr.datalen = (*env)->GetArrayLength(env, path);
1939         if (path_constr.datalen > 0)
1940                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
1941         else
1942                 path_constr.data = NULL;
1943         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
1944         for (size_t k = 0; k < path_constr.datalen; k++) {
1945                 int64_t path_conv_10 = path_vals[k];
1946                 LDKRouteHop path_conv_10_conv;
1947                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
1948                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
1949                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
1950                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
1951                 path_constr.data[k] = path_conv_10_conv;
1952         }
1953         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
1954         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
1955 }
1956
1957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
1958         void* this_arg_ptr = untag_ptr(this_arg);
1959         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1960         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
1961         LDKCVec_RouteHopZ path_constr;
1962         path_constr.datalen = (*env)->GetArrayLength(env, path);
1963         if (path_constr.datalen > 0)
1964                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
1965         else
1966                 path_constr.data = NULL;
1967         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
1968         for (size_t k = 0; k < path_constr.datalen; k++) {
1969                 int64_t path_conv_10 = path_vals[k];
1970                 LDKRouteHop path_conv_10_conv;
1971                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
1972                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
1973                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
1974                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
1975                 path_constr.data[k] = path_conv_10_conv;
1976         }
1977         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
1978         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
1979 }
1980
1981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1probe_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path, int64_t short_channel_id) {
1982         void* this_arg_ptr = untag_ptr(this_arg);
1983         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1984         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
1985         LDKCVec_RouteHopZ path_constr;
1986         path_constr.datalen = (*env)->GetArrayLength(env, path);
1987         if (path_constr.datalen > 0)
1988                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
1989         else
1990                 path_constr.data = NULL;
1991         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
1992         for (size_t k = 0; k < path_constr.datalen; k++) {
1993                 int64_t path_conv_10 = path_vals[k];
1994                 LDKRouteHop path_conv_10_conv;
1995                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
1996                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
1997                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
1998                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
1999                 path_constr.data[k] = path_conv_10_conv;
2000         }
2001         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
2002         (this_arg_conv->probe_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
2003 }
2004
2005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1probe_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
2006         void* this_arg_ptr = untag_ptr(this_arg);
2007         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2008         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2009         LDKCVec_RouteHopZ path_constr;
2010         path_constr.datalen = (*env)->GetArrayLength(env, path);
2011         if (path_constr.datalen > 0)
2012                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
2013         else
2014                 path_constr.data = NULL;
2015         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
2016         for (size_t k = 0; k < path_constr.datalen; k++) {
2017                 int64_t path_conv_10 = path_vals[k];
2018                 LDKRouteHop path_conv_10_conv;
2019                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
2020                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
2021                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
2022                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
2023                 path_constr.data[k] = path_conv_10_conv;
2024         }
2025         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
2026         (this_arg_conv->probe_successful)(this_arg_conv->this_arg, path_constr);
2027 }
2028
2029 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2030         void* this_arg_ptr = untag_ptr(this_arg);
2031         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2032         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2033         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2034         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2035         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2036         CVec_u8Z_free(ret_var);
2037         return ret_arr;
2038 }
2039
2040 typedef struct LDKLockableScore_JCalls {
2041         atomic_size_t refcnt;
2042         JavaVM *vm;
2043         jweak o;
2044         jmethodID lock_meth;
2045 } LDKLockableScore_JCalls;
2046 static void LDKLockableScore_JCalls_free(void* this_arg) {
2047         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
2048         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2049                 JNIEnv *env;
2050                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2051                 if (get_jenv_res == JNI_EDETACHED) {
2052                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2053                 } else {
2054                         DO_ASSERT(get_jenv_res == JNI_OK);
2055                 }
2056                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2057                 if (get_jenv_res == JNI_EDETACHED) {
2058                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2059                 }
2060                 FREE(j_calls);
2061         }
2062 }
2063 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
2064         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
2065         JNIEnv *env;
2066         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2067         if (get_jenv_res == JNI_EDETACHED) {
2068                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2069         } else {
2070                 DO_ASSERT(get_jenv_res == JNI_OK);
2071         }
2072         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2073         CHECK(obj != NULL);
2074         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
2075         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2076                 (*env)->ExceptionDescribe(env);
2077                 (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
2078         }
2079         void* ret_ptr = untag_ptr(ret);
2080         CHECK_ACCESS(ret_ptr);
2081         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
2082         if (ret_conv.free == LDKScore_JCalls_free) {
2083                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
2084                 LDKScore_JCalls_cloned(&ret_conv);
2085         }// WARNING: we may need a move here but no clone is available for LDKScore
2086         
2087         if (get_jenv_res == JNI_EDETACHED) {
2088                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2089         }
2090         return ret_conv;
2091 }
2092 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
2093         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
2094         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2095 }
2096 static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
2097         jclass c = (*env)->GetObjectClass(env, o);
2098         CHECK(c != NULL);
2099         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
2100         atomic_init(&calls->refcnt, 1);
2101         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2102         calls->o = (*env)->NewWeakGlobalRef(env, o);
2103         calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
2104         CHECK(calls->lock_meth != NULL);
2105
2106         LDKLockableScore ret = {
2107                 .this_arg = (void*) calls,
2108                 .lock = lock_LDKLockableScore_jcall,
2109                 .free = LDKLockableScore_JCalls_free,
2110         };
2111         return ret;
2112 }
2113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
2114         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
2115         *res_ptr = LDKLockableScore_init(env, clz, o);
2116         return tag_ptr(res_ptr, true);
2117 }
2118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
2119         void* this_arg_ptr = untag_ptr(this_arg);
2120         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2121         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
2122         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
2123         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
2124         return tag_ptr(ret_ret, true);
2125 }
2126
2127 typedef struct LDKWriteableScore_JCalls {
2128         atomic_size_t refcnt;
2129         JavaVM *vm;
2130         jweak o;
2131         LDKLockableScore_JCalls* LockableScore;
2132         jmethodID write_meth;
2133 } LDKWriteableScore_JCalls;
2134 static void LDKWriteableScore_JCalls_free(void* this_arg) {
2135         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) this_arg;
2136         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2137                 JNIEnv *env;
2138                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2139                 if (get_jenv_res == JNI_EDETACHED) {
2140                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2141                 } else {
2142                         DO_ASSERT(get_jenv_res == JNI_OK);
2143                 }
2144                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2145                 if (get_jenv_res == JNI_EDETACHED) {
2146                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2147                 }
2148                 FREE(j_calls);
2149         }
2150 }
2151 LDKCVec_u8Z write_LDKWriteableScore_jcall(const void* this_arg) {
2152         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) this_arg;
2153         JNIEnv *env;
2154         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2155         if (get_jenv_res == JNI_EDETACHED) {
2156                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2157         } else {
2158                 DO_ASSERT(get_jenv_res == JNI_OK);
2159         }
2160         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2161         CHECK(obj != NULL);
2162         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2163         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2164                 (*env)->ExceptionDescribe(env);
2165                 (*env)->FatalError(env, "A call to write in LDKWriteableScore from rust threw an exception.");
2166         }
2167         LDKCVec_u8Z ret_ref;
2168         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2169         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2170         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2171         if (get_jenv_res == JNI_EDETACHED) {
2172                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2173         }
2174         return ret_ref;
2175 }
2176 static void LDKWriteableScore_JCalls_cloned(LDKWriteableScore* new_obj) {
2177         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) new_obj->this_arg;
2178         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2179         atomic_fetch_add_explicit(&j_calls->LockableScore->refcnt, 1, memory_order_release);
2180 }
2181 static inline LDKWriteableScore LDKWriteableScore_init (JNIEnv *env, jclass clz, jobject o, jobject LockableScore) {
2182         jclass c = (*env)->GetObjectClass(env, o);
2183         CHECK(c != NULL);
2184         LDKWriteableScore_JCalls *calls = MALLOC(sizeof(LDKWriteableScore_JCalls), "LDKWriteableScore_JCalls");
2185         atomic_init(&calls->refcnt, 1);
2186         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2187         calls->o = (*env)->NewWeakGlobalRef(env, o);
2188         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2189         CHECK(calls->write_meth != NULL);
2190
2191         LDKWriteableScore ret = {
2192                 .this_arg = (void*) calls,
2193                 .write = write_LDKWriteableScore_jcall,
2194                 .free = LDKWriteableScore_JCalls_free,
2195                 .LockableScore = LDKLockableScore_init(env, clz, LockableScore),
2196         };
2197         calls->LockableScore = ret.LockableScore.this_arg;
2198         return ret;
2199 }
2200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableScore_1new(JNIEnv *env, jclass clz, jobject o, jobject LockableScore) {
2201         LDKWriteableScore *res_ptr = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
2202         *res_ptr = LDKWriteableScore_init(env, clz, o, LockableScore);
2203         return tag_ptr(res_ptr, true);
2204 }
2205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableScore_1get_1LockableScore(JNIEnv *env, jclass clz, int64_t arg) {
2206         LDKWriteableScore *inp = (LDKWriteableScore *)untag_ptr(arg);
2207         return tag_ptr(&inp->LockableScore, false);
2208 }
2209 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WriteableScore_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2210         void* this_arg_ptr = untag_ptr(this_arg);
2211         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2212         LDKWriteableScore* this_arg_conv = (LDKWriteableScore*)this_arg_ptr;
2213         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2214         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2215         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2216         CVec_u8Z_free(ret_var);
2217         return ret_arr;
2218 }
2219
2220 static jclass LDKCOption_WriteableScoreZ_Some_class = NULL;
2221 static jmethodID LDKCOption_WriteableScoreZ_Some_meth = NULL;
2222 static jclass LDKCOption_WriteableScoreZ_None_class = NULL;
2223 static jmethodID LDKCOption_WriteableScoreZ_None_meth = NULL;
2224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1WriteableScoreZ_init (JNIEnv *env, jclass clz) {
2225         LDKCOption_WriteableScoreZ_Some_class =
2226                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_WriteableScoreZ$Some"));
2227         CHECK(LDKCOption_WriteableScoreZ_Some_class != NULL);
2228         LDKCOption_WriteableScoreZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_WriteableScoreZ_Some_class, "<init>", "(J)V");
2229         CHECK(LDKCOption_WriteableScoreZ_Some_meth != NULL);
2230         LDKCOption_WriteableScoreZ_None_class =
2231                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_WriteableScoreZ$None"));
2232         CHECK(LDKCOption_WriteableScoreZ_None_class != NULL);
2233         LDKCOption_WriteableScoreZ_None_meth = (*env)->GetMethodID(env, LDKCOption_WriteableScoreZ_None_class, "<init>", "()V");
2234         CHECK(LDKCOption_WriteableScoreZ_None_meth != NULL);
2235 }
2236 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1WriteableScoreZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2237         LDKCOption_WriteableScoreZ *obj = (LDKCOption_WriteableScoreZ*)untag_ptr(ptr);
2238         switch(obj->tag) {
2239                 case LDKCOption_WriteableScoreZ_Some: {
2240                         LDKWriteableScore* some_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
2241                         *some_ret = obj->some;
2242                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
2243                         if ((*some_ret).free == LDKWriteableScore_JCalls_free) {
2244                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
2245                                 LDKWriteableScore_JCalls_cloned(&(*some_ret));
2246                         }
2247                         return (*env)->NewObject(env, LDKCOption_WriteableScoreZ_Some_class, LDKCOption_WriteableScoreZ_Some_meth, tag_ptr(some_ret, true));
2248                 }
2249                 case LDKCOption_WriteableScoreZ_None: {
2250                         return (*env)->NewObject(env, LDKCOption_WriteableScoreZ_None_class, LDKCOption_WriteableScoreZ_None_meth);
2251                 }
2252                 default: abort();
2253         }
2254 }
2255 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
2256 CHECK(owner->result_ok);
2257         return *owner->contents.result;
2258 }
2259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2260         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)untag_ptr(owner);
2261         CResult_NoneErrorZ_get_ok(owner_conv);
2262 }
2263
2264 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
2265 CHECK(!owner->result_ok);
2266         return *owner->contents.err;
2267 }
2268 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2269         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)untag_ptr(owner);
2270         jclass ret_conv = LDKIOError_to_java(env, CResult_NoneErrorZ_get_err(owner_conv));
2271         return ret_conv;
2272 }
2273
2274 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2275         LDKRouteHop ret = *owner->contents.result;
2276         ret.is_owned = false;
2277         return ret;
2278 }
2279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2280         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
2281         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
2282         int64_t ret_ref = 0;
2283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2284         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2285         return ret_ref;
2286 }
2287
2288 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2289         LDKDecodeError ret = *owner->contents.err;
2290         ret.is_owned = false;
2291         return ret;
2292 }
2293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2294         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
2295         LDKDecodeError ret_var = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
2296         int64_t ret_ref = 0;
2297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2298         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2299         return ret_ref;
2300 }
2301
2302 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
2303         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
2304         for (size_t i = 0; i < ret.datalen; i++) {
2305                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
2306         }
2307         return ret;
2308 }
2309 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
2310         LDKRoute ret = *owner->contents.result;
2311         ret.is_owned = false;
2312         return ret;
2313 }
2314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2315         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
2316         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
2317         int64_t ret_ref = 0;
2318         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2319         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2320         return ret_ref;
2321 }
2322
2323 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
2324         LDKDecodeError ret = *owner->contents.err;
2325         ret.is_owned = false;
2326         return ret;
2327 }
2328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2329         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
2330         LDKDecodeError ret_var = CResult_RouteDecodeErrorZ_get_err(owner_conv);
2331         int64_t ret_ref = 0;
2332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2333         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2334         return ret_ref;
2335 }
2336
2337 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
2338         LDKRouteParameters ret = *owner->contents.result;
2339         ret.is_owned = false;
2340         return ret;
2341 }
2342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2343         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
2344         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
2345         int64_t ret_ref = 0;
2346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2347         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2348         return ret_ref;
2349 }
2350
2351 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
2352         LDKDecodeError ret = *owner->contents.err;
2353         ret.is_owned = false;
2354         return ret;
2355 }
2356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2357         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
2358         LDKDecodeError ret_var = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
2359         int64_t ret_ref = 0;
2360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2361         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2362         return ret_ref;
2363 }
2364
2365 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
2366         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
2367         for (size_t i = 0; i < ret.datalen; i++) {
2368                 ret.data[i] = RouteHint_clone(&orig->data[i]);
2369         }
2370         return ret;
2371 }
2372 static jclass LDKCOption_u64Z_Some_class = NULL;
2373 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
2374 static jclass LDKCOption_u64Z_None_class = NULL;
2375 static jmethodID LDKCOption_u64Z_None_meth = NULL;
2376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
2377         LDKCOption_u64Z_Some_class =
2378                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$Some"));
2379         CHECK(LDKCOption_u64Z_Some_class != NULL);
2380         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
2381         CHECK(LDKCOption_u64Z_Some_meth != NULL);
2382         LDKCOption_u64Z_None_class =
2383                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$None"));
2384         CHECK(LDKCOption_u64Z_None_class != NULL);
2385         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
2386         CHECK(LDKCOption_u64Z_None_meth != NULL);
2387 }
2388 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2389         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)untag_ptr(ptr);
2390         switch(obj->tag) {
2391                 case LDKCOption_u64Z_Some: {
2392                         int64_t some_conv = obj->some;
2393                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, some_conv);
2394                 }
2395                 case LDKCOption_u64Z_None: {
2396                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
2397                 }
2398                 default: abort();
2399         }
2400 }
2401 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
2402         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
2403         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
2404         return ret;
2405 }
2406 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
2407         LDKPaymentParameters ret = *owner->contents.result;
2408         ret.is_owned = false;
2409         return ret;
2410 }
2411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2412         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
2413         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
2414         int64_t ret_ref = 0;
2415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2416         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2417         return ret_ref;
2418 }
2419
2420 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
2421         LDKDecodeError ret = *owner->contents.err;
2422         ret.is_owned = false;
2423         return ret;
2424 }
2425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2426         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
2427         LDKDecodeError ret_var = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
2428         int64_t ret_ref = 0;
2429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2430         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2431         return ret_ref;
2432 }
2433
2434 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
2435         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
2436         for (size_t i = 0; i < ret.datalen; i++) {
2437                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
2438         }
2439         return ret;
2440 }
2441 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
2442         LDKRouteHint ret = *owner->contents.result;
2443         ret.is_owned = false;
2444         return ret;
2445 }
2446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2447         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
2448         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
2449         int64_t ret_ref = 0;
2450         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2451         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2452         return ret_ref;
2453 }
2454
2455 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
2456         LDKDecodeError ret = *owner->contents.err;
2457         ret.is_owned = false;
2458         return ret;
2459 }
2460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2461         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
2462         LDKDecodeError ret_var = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
2463         int64_t ret_ref = 0;
2464         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2465         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2466         return ret_ref;
2467 }
2468
2469 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
2470         LDKRouteHintHop ret = *owner->contents.result;
2471         ret.is_owned = false;
2472         return ret;
2473 }
2474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2475         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
2476         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
2477         int64_t ret_ref = 0;
2478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2479         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2480         return ret_ref;
2481 }
2482
2483 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
2484         LDKDecodeError ret = *owner->contents.err;
2485         ret.is_owned = false;
2486         return ret;
2487 }
2488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2489         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
2490         LDKDecodeError ret_var = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
2491         int64_t ret_ref = 0;
2492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2493         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2494         return ret_ref;
2495 }
2496
2497 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
2498         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
2499         for (size_t i = 0; i < ret.datalen; i++) {
2500                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
2501         }
2502         return ret;
2503 }
2504 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2505         LDKRoute ret = *owner->contents.result;
2506         ret.is_owned = false;
2507         return ret;
2508 }
2509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2510         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
2511         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
2512         int64_t ret_ref = 0;
2513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2514         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2515         return ret_ref;
2516 }
2517
2518 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2519         LDKLightningError ret = *owner->contents.err;
2520         ret.is_owned = false;
2521         return ret;
2522 }
2523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2524         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
2525         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
2526         int64_t ret_ref = 0;
2527         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2528         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2529         return ret_ref;
2530 }
2531
2532 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
2533 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
2534 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
2535 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
2536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
2537         LDKPaymentPurpose_InvoicePayment_class =
2538                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment"));
2539         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
2540         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[B)V");
2541         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
2542         LDKPaymentPurpose_SpontaneousPayment_class =
2543                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment"));
2544         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
2545         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
2546         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
2547 }
2548 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2549         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)untag_ptr(ptr);
2550         switch(obj->tag) {
2551                 case LDKPaymentPurpose_InvoicePayment: {
2552                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2553                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
2554                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
2555                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
2556                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr);
2557                 }
2558                 case LDKPaymentPurpose_SpontaneousPayment: {
2559                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
2560                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
2561                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
2562                 }
2563                 default: abort();
2564         }
2565 }
2566 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
2567 CHECK(owner->result_ok);
2568         return PaymentPurpose_clone(&*owner->contents.result);
2569 }
2570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2571         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
2572         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
2573         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
2574         int64_t ret_ref = tag_ptr(ret_copy, true);
2575         return ret_ref;
2576 }
2577
2578 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
2579         LDKDecodeError ret = *owner->contents.err;
2580         ret.is_owned = false;
2581         return ret;
2582 }
2583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2584         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
2585         LDKDecodeError ret_var = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
2586         int64_t ret_ref = 0;
2587         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2588         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2589         return ret_ref;
2590 }
2591
2592 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
2593 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
2594 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
2595 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
2596 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
2597 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
2598 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
2599 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
2600 static jclass LDKClosureReason_FundingTimedOut_class = NULL;
2601 static jmethodID LDKClosureReason_FundingTimedOut_meth = NULL;
2602 static jclass LDKClosureReason_ProcessingError_class = NULL;
2603 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
2604 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
2605 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
2606 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
2607 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
2608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
2609         LDKClosureReason_CounterpartyForceClosed_class =
2610                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed"));
2611         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
2612         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
2613         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
2614         LDKClosureReason_HolderForceClosed_class =
2615                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$HolderForceClosed"));
2616         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
2617         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
2618         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
2619         LDKClosureReason_CooperativeClosure_class =
2620                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CooperativeClosure"));
2621         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
2622         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
2623         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
2624         LDKClosureReason_CommitmentTxConfirmed_class =
2625                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed"));
2626         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
2627         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
2628         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
2629         LDKClosureReason_FundingTimedOut_class =
2630                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$FundingTimedOut"));
2631         CHECK(LDKClosureReason_FundingTimedOut_class != NULL);
2632         LDKClosureReason_FundingTimedOut_meth = (*env)->GetMethodID(env, LDKClosureReason_FundingTimedOut_class, "<init>", "()V");
2633         CHECK(LDKClosureReason_FundingTimedOut_meth != NULL);
2634         LDKClosureReason_ProcessingError_class =
2635                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$ProcessingError"));
2636         CHECK(LDKClosureReason_ProcessingError_class != NULL);
2637         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
2638         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
2639         LDKClosureReason_DisconnectedPeer_class =
2640                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer"));
2641         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
2642         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
2643         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
2644         LDKClosureReason_OutdatedChannelManager_class =
2645                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager"));
2646         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
2647         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
2648         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
2649 }
2650 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2651         LDKClosureReason *obj = (LDKClosureReason*)untag_ptr(ptr);
2652         switch(obj->tag) {
2653                 case LDKClosureReason_CounterpartyForceClosed: {
2654                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
2655                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
2656                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
2657                 }
2658                 case LDKClosureReason_HolderForceClosed: {
2659                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
2660                 }
2661                 case LDKClosureReason_CooperativeClosure: {
2662                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
2663                 }
2664                 case LDKClosureReason_CommitmentTxConfirmed: {
2665                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
2666                 }
2667                 case LDKClosureReason_FundingTimedOut: {
2668                         return (*env)->NewObject(env, LDKClosureReason_FundingTimedOut_class, LDKClosureReason_FundingTimedOut_meth);
2669                 }
2670                 case LDKClosureReason_ProcessingError: {
2671                         LDKStr err_str = obj->processing_error.err;
2672                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2673                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
2674                 }
2675                 case LDKClosureReason_DisconnectedPeer: {
2676                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
2677                 }
2678                 case LDKClosureReason_OutdatedChannelManager: {
2679                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
2680                 }
2681                 default: abort();
2682         }
2683 }
2684 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
2685 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
2686 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
2687 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
2688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
2689         LDKCOption_ClosureReasonZ_Some_class =
2690                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some"));
2691         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
2692         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
2693         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
2694         LDKCOption_ClosureReasonZ_None_class =
2695                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None"));
2696         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
2697         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
2698         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
2699 }
2700 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2701         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)untag_ptr(ptr);
2702         switch(obj->tag) {
2703                 case LDKCOption_ClosureReasonZ_Some: {
2704                         int64_t some_ref = tag_ptr(&obj->some, false);
2705                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
2706                 }
2707                 case LDKCOption_ClosureReasonZ_None: {
2708                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
2709                 }
2710                 default: abort();
2711         }
2712 }
2713 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2714 CHECK(owner->result_ok);
2715         return COption_ClosureReasonZ_clone(&*owner->contents.result);
2716 }
2717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2718         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
2719         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
2720         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
2721         int64_t ret_ref = tag_ptr(ret_copy, true);
2722         return ret_ref;
2723 }
2724
2725 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2726         LDKDecodeError ret = *owner->contents.err;
2727         ret.is_owned = false;
2728         return ret;
2729 }
2730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2731         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
2732         LDKDecodeError ret_var = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
2733         int64_t ret_ref = 0;
2734         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2735         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2736         return ret_ref;
2737 }
2738
2739 static jclass LDKHTLCDestination_NextHopChannel_class = NULL;
2740 static jmethodID LDKHTLCDestination_NextHopChannel_meth = NULL;
2741 static jclass LDKHTLCDestination_UnknownNextHop_class = NULL;
2742 static jmethodID LDKHTLCDestination_UnknownNextHop_meth = NULL;
2743 static jclass LDKHTLCDestination_FailedPayment_class = NULL;
2744 static jmethodID LDKHTLCDestination_FailedPayment_meth = NULL;
2745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCDestination_init (JNIEnv *env, jclass clz) {
2746         LDKHTLCDestination_NextHopChannel_class =
2747                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$NextHopChannel"));
2748         CHECK(LDKHTLCDestination_NextHopChannel_class != NULL);
2749         LDKHTLCDestination_NextHopChannel_meth = (*env)->GetMethodID(env, LDKHTLCDestination_NextHopChannel_class, "<init>", "([B[B)V");
2750         CHECK(LDKHTLCDestination_NextHopChannel_meth != NULL);
2751         LDKHTLCDestination_UnknownNextHop_class =
2752                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$UnknownNextHop"));
2753         CHECK(LDKHTLCDestination_UnknownNextHop_class != NULL);
2754         LDKHTLCDestination_UnknownNextHop_meth = (*env)->GetMethodID(env, LDKHTLCDestination_UnknownNextHop_class, "<init>", "(J)V");
2755         CHECK(LDKHTLCDestination_UnknownNextHop_meth != NULL);
2756         LDKHTLCDestination_FailedPayment_class =
2757                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$FailedPayment"));
2758         CHECK(LDKHTLCDestination_FailedPayment_class != NULL);
2759         LDKHTLCDestination_FailedPayment_meth = (*env)->GetMethodID(env, LDKHTLCDestination_FailedPayment_class, "<init>", "([B)V");
2760         CHECK(LDKHTLCDestination_FailedPayment_meth != NULL);
2761 }
2762 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCDestination_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2763         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
2764         switch(obj->tag) {
2765                 case LDKHTLCDestination_NextHopChannel: {
2766                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2767                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->next_hop_channel.node_id.compressed_form);
2768                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2769                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->next_hop_channel.channel_id.data);
2770                         return (*env)->NewObject(env, LDKHTLCDestination_NextHopChannel_class, LDKHTLCDestination_NextHopChannel_meth, node_id_arr, channel_id_arr);
2771                 }
2772                 case LDKHTLCDestination_UnknownNextHop: {
2773                         int64_t requested_forward_scid_conv = obj->unknown_next_hop.requested_forward_scid;
2774                         return (*env)->NewObject(env, LDKHTLCDestination_UnknownNextHop_class, LDKHTLCDestination_UnknownNextHop_meth, requested_forward_scid_conv);
2775                 }
2776                 case LDKHTLCDestination_FailedPayment: {
2777                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2778                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->failed_payment.payment_hash.data);
2779                         return (*env)->NewObject(env, LDKHTLCDestination_FailedPayment_class, LDKHTLCDestination_FailedPayment_meth, payment_hash_arr);
2780                 }
2781                 default: abort();
2782         }
2783 }
2784 static jclass LDKCOption_HTLCDestinationZ_Some_class = NULL;
2785 static jmethodID LDKCOption_HTLCDestinationZ_Some_meth = NULL;
2786 static jclass LDKCOption_HTLCDestinationZ_None_class = NULL;
2787 static jmethodID LDKCOption_HTLCDestinationZ_None_meth = NULL;
2788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1HTLCDestinationZ_init (JNIEnv *env, jclass clz) {
2789         LDKCOption_HTLCDestinationZ_Some_class =
2790                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$Some"));
2791         CHECK(LDKCOption_HTLCDestinationZ_Some_class != NULL);
2792         LDKCOption_HTLCDestinationZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_Some_class, "<init>", "(J)V");
2793         CHECK(LDKCOption_HTLCDestinationZ_Some_meth != NULL);
2794         LDKCOption_HTLCDestinationZ_None_class =
2795                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$None"));
2796         CHECK(LDKCOption_HTLCDestinationZ_None_class != NULL);
2797         LDKCOption_HTLCDestinationZ_None_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_None_class, "<init>", "()V");
2798         CHECK(LDKCOption_HTLCDestinationZ_None_meth != NULL);
2799 }
2800 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1HTLCDestinationZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2801         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)untag_ptr(ptr);
2802         switch(obj->tag) {
2803                 case LDKCOption_HTLCDestinationZ_Some: {
2804                         int64_t some_ref = tag_ptr(&obj->some, false);
2805                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_Some_class, LDKCOption_HTLCDestinationZ_Some_meth, some_ref);
2806                 }
2807                 case LDKCOption_HTLCDestinationZ_None: {
2808                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_None_class, LDKCOption_HTLCDestinationZ_None_meth);
2809                 }
2810                 default: abort();
2811         }
2812 }
2813 static inline struct LDKCOption_HTLCDestinationZ CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
2814 CHECK(owner->result_ok);
2815         return COption_HTLCDestinationZ_clone(&*owner->contents.result);
2816 }
2817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2818         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
2819         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
2820         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(owner_conv);
2821         int64_t ret_ref = tag_ptr(ret_copy, true);
2822         return ret_ref;
2823 }
2824
2825 static inline struct LDKDecodeError CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
2826         LDKDecodeError ret = *owner->contents.err;
2827         ret.is_owned = false;
2828         return ret;
2829 }
2830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2831         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
2832         LDKDecodeError ret_var = CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(owner_conv);
2833         int64_t ret_ref = 0;
2834         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2835         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2836         return ret_ref;
2837 }
2838
2839 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
2840 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
2841 static jclass LDKNetworkUpdate_ChannelFailure_class = NULL;
2842 static jmethodID LDKNetworkUpdate_ChannelFailure_meth = NULL;
2843 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
2844 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
2845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
2846         LDKNetworkUpdate_ChannelUpdateMessage_class =
2847                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage"));
2848         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
2849         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
2850         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
2851         LDKNetworkUpdate_ChannelFailure_class =
2852                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelFailure"));
2853         CHECK(LDKNetworkUpdate_ChannelFailure_class != NULL);
2854         LDKNetworkUpdate_ChannelFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelFailure_class, "<init>", "(JZ)V");
2855         CHECK(LDKNetworkUpdate_ChannelFailure_meth != NULL);
2856         LDKNetworkUpdate_NodeFailure_class =
2857                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure"));
2858         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
2859         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
2860         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
2861 }
2862 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2863         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
2864         switch(obj->tag) {
2865                 case LDKNetworkUpdate_ChannelUpdateMessage: {
2866                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
2867                         int64_t msg_ref = 0;
2868                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2869                         msg_ref = tag_ptr(msg_var.inner, false);
2870                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
2871                 }
2872                 case LDKNetworkUpdate_ChannelFailure: {
2873                         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
2874                         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
2875                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelFailure_class, LDKNetworkUpdate_ChannelFailure_meth, short_channel_id_conv, is_permanent_conv);
2876                 }
2877                 case LDKNetworkUpdate_NodeFailure: {
2878                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2879                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
2880                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
2881                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, is_permanent_conv);
2882                 }
2883                 default: abort();
2884         }
2885 }
2886 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
2887 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
2888 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
2889 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
2890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
2891         LDKCOption_NetworkUpdateZ_Some_class =
2892                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some"));
2893         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
2894         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
2895         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
2896         LDKCOption_NetworkUpdateZ_None_class =
2897                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None"));
2898         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
2899         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
2900         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
2901 }
2902 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2903         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)untag_ptr(ptr);
2904         switch(obj->tag) {
2905                 case LDKCOption_NetworkUpdateZ_Some: {
2906                         int64_t some_ref = tag_ptr(&obj->some, false);
2907                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
2908                 }
2909                 case LDKCOption_NetworkUpdateZ_None: {
2910                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
2911                 }
2912                 default: abort();
2913         }
2914 }
2915 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
2916 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
2917 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
2918 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
2919 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
2920 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
2921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
2922         LDKSpendableOutputDescriptor_StaticOutput_class =
2923                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput"));
2924         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
2925         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
2926         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
2927         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
2928                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput"));
2929         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
2930         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
2931         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
2932         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
2933                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput"));
2934         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
2935         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
2936         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
2937 }
2938 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2939         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
2940         switch(obj->tag) {
2941                 case LDKSpendableOutputDescriptor_StaticOutput: {
2942                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
2943                         int64_t outpoint_ref = 0;
2944                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
2945                         outpoint_ref = tag_ptr(outpoint_var.inner, false);
2946                         LDKTxOut* output_ref = &obj->static_output.output;
2947                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, tag_ptr(output_ref, false));
2948                 }
2949                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
2950                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
2951                         int64_t delayed_payment_output_ref = 0;
2952                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
2953                         delayed_payment_output_ref = tag_ptr(delayed_payment_output_var.inner, false);
2954                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
2955                 }
2956                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
2957                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
2958                         int64_t static_payment_output_ref = 0;
2959                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
2960                         static_payment_output_ref = tag_ptr(static_payment_output_var.inner, false);
2961                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
2962                 }
2963                 default: abort();
2964         }
2965 }
2966 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
2967         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
2968         for (size_t i = 0; i < ret.datalen; i++) {
2969                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
2970         }
2971         return ret;
2972 }
2973 static jclass LDKEvent_FundingGenerationReady_class = NULL;
2974 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
2975 static jclass LDKEvent_PaymentReceived_class = NULL;
2976 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
2977 static jclass LDKEvent_PaymentClaimed_class = NULL;
2978 static jmethodID LDKEvent_PaymentClaimed_meth = NULL;
2979 static jclass LDKEvent_PaymentSent_class = NULL;
2980 static jmethodID LDKEvent_PaymentSent_meth = NULL;
2981 static jclass LDKEvent_PaymentFailed_class = NULL;
2982 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
2983 static jclass LDKEvent_PaymentPathSuccessful_class = NULL;
2984 static jmethodID LDKEvent_PaymentPathSuccessful_meth = NULL;
2985 static jclass LDKEvent_PaymentPathFailed_class = NULL;
2986 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
2987 static jclass LDKEvent_ProbeSuccessful_class = NULL;
2988 static jmethodID LDKEvent_ProbeSuccessful_meth = NULL;
2989 static jclass LDKEvent_ProbeFailed_class = NULL;
2990 static jmethodID LDKEvent_ProbeFailed_meth = NULL;
2991 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
2992 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
2993 static jclass LDKEvent_SpendableOutputs_class = NULL;
2994 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
2995 static jclass LDKEvent_PaymentForwarded_class = NULL;
2996 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
2997 static jclass LDKEvent_ChannelClosed_class = NULL;
2998 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
2999 static jclass LDKEvent_DiscardFunding_class = NULL;
3000 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
3001 static jclass LDKEvent_OpenChannelRequest_class = NULL;
3002 static jmethodID LDKEvent_OpenChannelRequest_meth = NULL;
3003 static jclass LDKEvent_HTLCHandlingFailed_class = NULL;
3004 static jmethodID LDKEvent_HTLCHandlingFailed_meth = NULL;
3005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
3006         LDKEvent_FundingGenerationReady_class =
3007                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$FundingGenerationReady"));
3008         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
3009         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([B[BJ[BJ)V");
3010         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
3011         LDKEvent_PaymentReceived_class =
3012                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentReceived"));
3013         CHECK(LDKEvent_PaymentReceived_class != NULL);
3014         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
3015         CHECK(LDKEvent_PaymentReceived_meth != NULL);
3016         LDKEvent_PaymentClaimed_class =
3017                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentClaimed"));
3018         CHECK(LDKEvent_PaymentClaimed_class != NULL);
3019         LDKEvent_PaymentClaimed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentClaimed_class, "<init>", "([BJJ)V");
3020         CHECK(LDKEvent_PaymentClaimed_meth != NULL);
3021         LDKEvent_PaymentSent_class =
3022                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentSent"));
3023         CHECK(LDKEvent_PaymentSent_class != NULL);
3024         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
3025         CHECK(LDKEvent_PaymentSent_meth != NULL);
3026         LDKEvent_PaymentFailed_class =
3027                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentFailed"));
3028         CHECK(LDKEvent_PaymentFailed_class != NULL);
3029         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([B[B)V");
3030         CHECK(LDKEvent_PaymentFailed_meth != NULL);
3031         LDKEvent_PaymentPathSuccessful_class =
3032                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathSuccessful"));
3033         CHECK(LDKEvent_PaymentPathSuccessful_class != NULL);
3034         LDKEvent_PaymentPathSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathSuccessful_class, "<init>", "([B[B[J)V");
3035         CHECK(LDKEvent_PaymentPathSuccessful_meth != NULL);
3036         LDKEvent_PaymentPathFailed_class =
3037                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathFailed"));
3038         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
3039         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
3040         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
3041         LDKEvent_ProbeSuccessful_class =
3042                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeSuccessful"));
3043         CHECK(LDKEvent_ProbeSuccessful_class != NULL);
3044         LDKEvent_ProbeSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_ProbeSuccessful_class, "<init>", "([B[B[J)V");
3045         CHECK(LDKEvent_ProbeSuccessful_meth != NULL);
3046         LDKEvent_ProbeFailed_class =
3047                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeFailed"));
3048         CHECK(LDKEvent_ProbeFailed_class != NULL);
3049         LDKEvent_ProbeFailed_meth = (*env)->GetMethodID(env, LDKEvent_ProbeFailed_class, "<init>", "([B[B[JJ)V");
3050         CHECK(LDKEvent_ProbeFailed_meth != NULL);
3051         LDKEvent_PendingHTLCsForwardable_class =
3052                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable"));
3053         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
3054         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
3055         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
3056         LDKEvent_SpendableOutputs_class =
3057                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$SpendableOutputs"));
3058         CHECK(LDKEvent_SpendableOutputs_class != NULL);
3059         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
3060         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
3061         LDKEvent_PaymentForwarded_class =
3062                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentForwarded"));
3063         CHECK(LDKEvent_PaymentForwarded_class != NULL);
3064         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "([B[BJZ)V");
3065         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
3066         LDKEvent_ChannelClosed_class =
3067                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelClosed"));
3068         CHECK(LDKEvent_ChannelClosed_class != NULL);
3069         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
3070         CHECK(LDKEvent_ChannelClosed_meth != NULL);
3071         LDKEvent_DiscardFunding_class =
3072                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$DiscardFunding"));
3073         CHECK(LDKEvent_DiscardFunding_class != NULL);
3074         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
3075         CHECK(LDKEvent_DiscardFunding_meth != NULL);
3076         LDKEvent_OpenChannelRequest_class =
3077                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$OpenChannelRequest"));
3078         CHECK(LDKEvent_OpenChannelRequest_class != NULL);
3079         LDKEvent_OpenChannelRequest_meth = (*env)->GetMethodID(env, LDKEvent_OpenChannelRequest_class, "<init>", "([B[BJJJ)V");
3080         CHECK(LDKEvent_OpenChannelRequest_meth != NULL);
3081         LDKEvent_HTLCHandlingFailed_class =
3082                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$HTLCHandlingFailed"));
3083         CHECK(LDKEvent_HTLCHandlingFailed_class != NULL);
3084         LDKEvent_HTLCHandlingFailed_meth = (*env)->GetMethodID(env, LDKEvent_HTLCHandlingFailed_class, "<init>", "([BJ)V");
3085         CHECK(LDKEvent_HTLCHandlingFailed_meth != NULL);
3086 }
3087 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3088         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
3089         switch(obj->tag) {
3090                 case LDKEvent_FundingGenerationReady: {
3091                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
3092                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
3093                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
3094                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->funding_generation_ready.counterparty_node_id.compressed_form);
3095                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
3096                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
3097                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
3098                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
3099                         int64_t user_channel_id_conv = obj->funding_generation_ready.user_channel_id;
3100                         return (*env)->NewObject(env, LDKEvent_FundingGenerationReady_class, LDKEvent_FundingGenerationReady_meth, temporary_channel_id_arr, counterparty_node_id_arr, channel_value_satoshis_conv, output_script_arr, user_channel_id_conv);
3101                 }
3102                 case LDKEvent_PaymentReceived: {
3103                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3104                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
3105                         int64_t amount_msat_conv = obj->payment_received.amount_msat;
3106                         int64_t purpose_ref = tag_ptr(&obj->payment_received.purpose, false);
3107                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, amount_msat_conv, purpose_ref);
3108                 }
3109                 case LDKEvent_PaymentClaimed: {
3110                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3111                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_claimed.payment_hash.data);
3112                         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
3113                         int64_t purpose_ref = tag_ptr(&obj->payment_claimed.purpose, false);
3114                         return (*env)->NewObject(env, LDKEvent_PaymentClaimed_class, LDKEvent_PaymentClaimed_meth, payment_hash_arr, amount_msat_conv, purpose_ref);
3115                 }
3116                 case LDKEvent_PaymentSent: {
3117                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3118                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
3119                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
3120                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
3121                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3122                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
3123                         int64_t fee_paid_msat_ref = tag_ptr(&obj->payment_sent.fee_paid_msat, false);
3124                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
3125                 }
3126                 case LDKEvent_PaymentFailed: {
3127                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3128                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_failed.payment_id.data);
3129                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3130                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
3131                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_id_arr, payment_hash_arr);
3132                 }
3133                 case LDKEvent_PaymentPathSuccessful: {
3134                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3135                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_successful.payment_id.data);
3136                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3137                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_successful.payment_hash.data);
3138                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
3139                         int64_tArray path_arr = NULL;
3140                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3141                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3142                         for (size_t k = 0; k < path_var.datalen; k++) {
3143                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3144                                 int64_t path_conv_10_ref = 0;
3145                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3146                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3147                                 path_arr_ptr[k] = path_conv_10_ref;
3148                         }
3149                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3150                         return (*env)->NewObject(env, LDKEvent_PaymentPathSuccessful_class, LDKEvent_PaymentPathSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
3151                 }
3152                 case LDKEvent_PaymentPathFailed: {
3153                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3154                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
3155                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3156                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
3157                         jboolean payment_failed_permanently_conv = obj->payment_path_failed.payment_failed_permanently;
3158                         int64_t network_update_ref = tag_ptr(&obj->payment_path_failed.network_update, false);
3159                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
3160                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
3161                         int64_tArray path_arr = NULL;
3162                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3163                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3164                         for (size_t k = 0; k < path_var.datalen; k++) {
3165                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3166                                 int64_t path_conv_10_ref = 0;
3167                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3168                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3169                                 path_arr_ptr[k] = path_conv_10_ref;
3170                         }
3171                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3172                         int64_t short_channel_id_ref = tag_ptr(&obj->payment_path_failed.short_channel_id, false);
3173                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
3174                         int64_t retry_ref = 0;
3175                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
3176                         retry_ref = tag_ptr(retry_var.inner, false);
3177                         return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_id_arr, payment_hash_arr, payment_failed_permanently_conv, network_update_ref, all_paths_failed_conv, path_arr, short_channel_id_ref, retry_ref);
3178                 }
3179                 case LDKEvent_ProbeSuccessful: {
3180                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3181                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_successful.payment_id.data);
3182                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3183                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_successful.payment_hash.data);
3184                         LDKCVec_RouteHopZ path_var = obj->probe_successful.path;
3185                         int64_tArray path_arr = NULL;
3186                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3187                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3188                         for (size_t k = 0; k < path_var.datalen; k++) {
3189                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3190                                 int64_t path_conv_10_ref = 0;
3191                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3192                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3193                                 path_arr_ptr[k] = path_conv_10_ref;
3194                         }
3195                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3196                         return (*env)->NewObject(env, LDKEvent_ProbeSuccessful_class, LDKEvent_ProbeSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
3197                 }
3198                 case LDKEvent_ProbeFailed: {
3199                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3200                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_failed.payment_id.data);
3201                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3202                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_failed.payment_hash.data);
3203                         LDKCVec_RouteHopZ path_var = obj->probe_failed.path;
3204                         int64_tArray path_arr = NULL;
3205                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3206                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3207                         for (size_t k = 0; k < path_var.datalen; k++) {
3208                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3209                                 int64_t path_conv_10_ref = 0;
3210                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3211                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3212                                 path_arr_ptr[k] = path_conv_10_ref;
3213                         }
3214                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3215                         int64_t short_channel_id_ref = tag_ptr(&obj->probe_failed.short_channel_id, false);
3216                         return (*env)->NewObject(env, LDKEvent_ProbeFailed_class, LDKEvent_ProbeFailed_meth, payment_id_arr, payment_hash_arr, path_arr, short_channel_id_ref);
3217                 }
3218                 case LDKEvent_PendingHTLCsForwardable: {
3219                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
3220                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, time_forwardable_conv);
3221                 }
3222                 case LDKEvent_SpendableOutputs: {
3223                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
3224                         int64_tArray outputs_arr = NULL;
3225                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
3226                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
3227                         for (size_t b = 0; b < outputs_var.datalen; b++) {
3228                                 int64_t outputs_conv_27_ref = tag_ptr(&outputs_var.data[b], false);
3229                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
3230                         }
3231                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
3232                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
3233                 }
3234                 case LDKEvent_PaymentForwarded: {
3235                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
3236                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->payment_forwarded.prev_channel_id.data);
3237                         int8_tArray next_channel_id_arr = (*env)->NewByteArray(env, 32);
3238                         (*env)->SetByteArrayRegion(env, next_channel_id_arr, 0, 32, obj->payment_forwarded.next_channel_id.data);
3239                         int64_t fee_earned_msat_ref = tag_ptr(&obj->payment_forwarded.fee_earned_msat, false);
3240                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
3241                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, prev_channel_id_arr, next_channel_id_arr, fee_earned_msat_ref, claim_from_onchain_tx_conv);
3242                 }
3243                 case LDKEvent_ChannelClosed: {
3244                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
3245                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
3246                         int64_t user_channel_id_conv = obj->channel_closed.user_channel_id;
3247                         int64_t reason_ref = tag_ptr(&obj->channel_closed.reason, false);
3248                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, user_channel_id_conv, reason_ref);
3249                 }
3250                 case LDKEvent_DiscardFunding: {
3251                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
3252                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
3253                         LDKTransaction transaction_var = obj->discard_funding.transaction;
3254                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
3255                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
3256                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
3257                 }
3258                 case LDKEvent_OpenChannelRequest: {
3259                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
3260                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->open_channel_request.temporary_channel_id.data);
3261                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
3262                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->open_channel_request.counterparty_node_id.compressed_form);
3263                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
3264                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
3265                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
3266                         int64_t channel_type_ref = 0;
3267                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
3268                         channel_type_ref = tag_ptr(channel_type_var.inner, false);
3269                         return (*env)->NewObject(env, LDKEvent_OpenChannelRequest_class, LDKEvent_OpenChannelRequest_meth, temporary_channel_id_arr, counterparty_node_id_arr, funding_satoshis_conv, push_msat_conv, channel_type_ref);
3270                 }
3271                 case LDKEvent_HTLCHandlingFailed: {
3272                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
3273                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->htlc_handling_failed.prev_channel_id.data);
3274                         int64_t failed_next_destination_ref = tag_ptr(&obj->htlc_handling_failed.failed_next_destination, false);
3275                         return (*env)->NewObject(env, LDKEvent_HTLCHandlingFailed_class, LDKEvent_HTLCHandlingFailed_meth, prev_channel_id_arr, failed_next_destination_ref);
3276                 }
3277                 default: abort();
3278         }
3279 }
3280 static jclass LDKCOption_EventZ_Some_class = NULL;
3281 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
3282 static jclass LDKCOption_EventZ_None_class = NULL;
3283 static jmethodID LDKCOption_EventZ_None_meth = NULL;
3284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
3285         LDKCOption_EventZ_Some_class =
3286                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$Some"));
3287         CHECK(LDKCOption_EventZ_Some_class != NULL);
3288         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
3289         CHECK(LDKCOption_EventZ_Some_meth != NULL);
3290         LDKCOption_EventZ_None_class =
3291                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$None"));
3292         CHECK(LDKCOption_EventZ_None_class != NULL);
3293         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
3294         CHECK(LDKCOption_EventZ_None_meth != NULL);
3295 }
3296 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3297         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)untag_ptr(ptr);
3298         switch(obj->tag) {
3299                 case LDKCOption_EventZ_Some: {
3300                         int64_t some_ref = tag_ptr(&obj->some, false);
3301                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
3302                 }
3303                 case LDKCOption_EventZ_None: {
3304                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
3305                 }
3306                 default: abort();
3307         }
3308 }
3309 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
3310 CHECK(owner->result_ok);
3311         return COption_EventZ_clone(&*owner->contents.result);
3312 }
3313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3314         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
3315         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
3316         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
3317         int64_t ret_ref = tag_ptr(ret_copy, true);
3318         return ret_ref;
3319 }
3320
3321 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
3322         LDKDecodeError ret = *owner->contents.err;
3323         ret.is_owned = false;
3324         return ret;
3325 }
3326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3327         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
3328         LDKDecodeError ret_var = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
3329         int64_t ret_ref = 0;
3330         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3331         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3332         return ret_ref;
3333 }
3334
3335 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
3336 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
3337 static jclass LDKErrorAction_IgnoreError_class = NULL;
3338 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
3339 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
3340 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
3341 static jclass LDKErrorAction_IgnoreDuplicateGossip_class = NULL;
3342 static jmethodID LDKErrorAction_IgnoreDuplicateGossip_meth = NULL;
3343 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
3344 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
3345 static jclass LDKErrorAction_SendWarningMessage_class = NULL;
3346 static jmethodID LDKErrorAction_SendWarningMessage_meth = NULL;
3347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
3348         LDKErrorAction_DisconnectPeer_class =
3349                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$DisconnectPeer"));
3350         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
3351         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
3352         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
3353         LDKErrorAction_IgnoreError_class =
3354                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreError"));
3355         CHECK(LDKErrorAction_IgnoreError_class != NULL);
3356         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
3357         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
3358         LDKErrorAction_IgnoreAndLog_class =
3359                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog"));
3360         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
3361         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
3362         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
3363         LDKErrorAction_IgnoreDuplicateGossip_class =
3364                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreDuplicateGossip"));
3365         CHECK(LDKErrorAction_IgnoreDuplicateGossip_class != NULL);
3366         LDKErrorAction_IgnoreDuplicateGossip_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreDuplicateGossip_class, "<init>", "()V");
3367         CHECK(LDKErrorAction_IgnoreDuplicateGossip_meth != NULL);
3368         LDKErrorAction_SendErrorMessage_class =
3369                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendErrorMessage"));
3370         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
3371         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
3372         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
3373         LDKErrorAction_SendWarningMessage_class =
3374                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendWarningMessage"));
3375         CHECK(LDKErrorAction_SendWarningMessage_class != NULL);
3376         LDKErrorAction_SendWarningMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendWarningMessage_class, "<init>", "(JLorg/ldk/enums/Level;)V");
3377         CHECK(LDKErrorAction_SendWarningMessage_meth != NULL);
3378 }
3379 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3380         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
3381         switch(obj->tag) {
3382                 case LDKErrorAction_DisconnectPeer: {
3383                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
3384                         int64_t msg_ref = 0;
3385                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3386                         msg_ref = tag_ptr(msg_var.inner, false);
3387                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
3388                 }
3389                 case LDKErrorAction_IgnoreError: {
3390                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
3391                 }
3392                 case LDKErrorAction_IgnoreAndLog: {
3393                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
3394                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
3395                 }
3396                 case LDKErrorAction_IgnoreDuplicateGossip: {
3397                         return (*env)->NewObject(env, LDKErrorAction_IgnoreDuplicateGossip_class, LDKErrorAction_IgnoreDuplicateGossip_meth);
3398                 }
3399                 case LDKErrorAction_SendErrorMessage: {
3400                         LDKErrorMessage msg_var = obj->send_error_message.msg;
3401                         int64_t msg_ref = 0;
3402                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3403                         msg_ref = tag_ptr(msg_var.inner, false);
3404                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
3405                 }
3406                 case LDKErrorAction_SendWarningMessage: {
3407                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
3408                         int64_t msg_ref = 0;
3409                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3410                         msg_ref = tag_ptr(msg_var.inner, false);
3411                         jclass log_level_conv = LDKLevel_to_java(env, obj->send_warning_message.log_level);
3412                         return (*env)->NewObject(env, LDKErrorAction_SendWarningMessage_class, LDKErrorAction_SendWarningMessage_meth, msg_ref, log_level_conv);
3413                 }
3414                 default: abort();
3415         }
3416 }
3417 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
3418 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
3419 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
3420 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
3421 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
3422 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
3423 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
3424 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
3425 static jclass LDKMessageSendEvent_SendChannelReady_class = NULL;
3426 static jmethodID LDKMessageSendEvent_SendChannelReady_meth = NULL;
3427 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
3428 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
3429 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
3430 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
3431 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
3432 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
3433 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
3434 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
3435 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
3436 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
3437 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
3438 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
3439 static jclass LDKMessageSendEvent_SendChannelAnnouncement_class = NULL;
3440 static jmethodID LDKMessageSendEvent_SendChannelAnnouncement_meth = NULL;
3441 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
3442 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
3443 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
3444 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
3445 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
3446 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
3447 static jclass LDKMessageSendEvent_HandleError_class = NULL;
3448 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
3449 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
3450 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
3451 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
3452 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
3453 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
3454 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
3455 static jclass LDKMessageSendEvent_SendGossipTimestampFilter_class = NULL;
3456 static jmethodID LDKMessageSendEvent_SendGossipTimestampFilter_meth = NULL;
3457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
3458         LDKMessageSendEvent_SendAcceptChannel_class =
3459                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
3460         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
3461         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
3462         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
3463         LDKMessageSendEvent_SendOpenChannel_class =
3464                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
3465         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
3466         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
3467         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
3468         LDKMessageSendEvent_SendFundingCreated_class =
3469                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
3470         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
3471         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
3472         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
3473         LDKMessageSendEvent_SendFundingSigned_class =
3474                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
3475         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
3476         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
3477         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
3478         LDKMessageSendEvent_SendChannelReady_class =
3479                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReady"));
3480         CHECK(LDKMessageSendEvent_SendChannelReady_class != NULL);
3481         LDKMessageSendEvent_SendChannelReady_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReady_class, "<init>", "([BJ)V");
3482         CHECK(LDKMessageSendEvent_SendChannelReady_meth != NULL);
3483         LDKMessageSendEvent_SendAnnouncementSignatures_class =
3484                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
3485         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
3486         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
3487         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
3488         LDKMessageSendEvent_UpdateHTLCs_class =
3489                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
3490         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
3491         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
3492         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
3493         LDKMessageSendEvent_SendRevokeAndACK_class =
3494                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
3495         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
3496         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
3497         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
3498         LDKMessageSendEvent_SendClosingSigned_class =
3499                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
3500         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
3501         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
3502         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
3503         LDKMessageSendEvent_SendShutdown_class =
3504                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
3505         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
3506         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
3507         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
3508         LDKMessageSendEvent_SendChannelReestablish_class =
3509                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
3510         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
3511         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
3512         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
3513         LDKMessageSendEvent_SendChannelAnnouncement_class =
3514                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelAnnouncement"));
3515         CHECK(LDKMessageSendEvent_SendChannelAnnouncement_class != NULL);
3516         LDKMessageSendEvent_SendChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelAnnouncement_class, "<init>", "([BJJ)V");
3517         CHECK(LDKMessageSendEvent_SendChannelAnnouncement_meth != NULL);
3518         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
3519                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
3520         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
3521         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
3522         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
3523         LDKMessageSendEvent_BroadcastChannelUpdate_class =
3524                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
3525         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
3526         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
3527         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
3528         LDKMessageSendEvent_SendChannelUpdate_class =
3529                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
3530         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
3531         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
3532         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
3533         LDKMessageSendEvent_HandleError_class =
3534                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
3535         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
3536         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
3537         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
3538         LDKMessageSendEvent_SendChannelRangeQuery_class =
3539                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
3540         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
3541         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
3542         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
3543         LDKMessageSendEvent_SendShortIdsQuery_class =
3544                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
3545         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
3546         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
3547         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
3548         LDKMessageSendEvent_SendReplyChannelRange_class =
3549                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
3550         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
3551         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
3552         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
3553         LDKMessageSendEvent_SendGossipTimestampFilter_class =
3554                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendGossipTimestampFilter"));
3555         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_class != NULL);
3556         LDKMessageSendEvent_SendGossipTimestampFilter_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, "<init>", "([BJ)V");
3557         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_meth != NULL);
3558 }
3559 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3560         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
3561         switch(obj->tag) {
3562                 case LDKMessageSendEvent_SendAcceptChannel: {
3563                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3564                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
3565                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
3566                         int64_t msg_ref = 0;
3567                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3568                         msg_ref = tag_ptr(msg_var.inner, false);
3569                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
3570                 }
3571                 case LDKMessageSendEvent_SendOpenChannel: {
3572                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3573                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
3574                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
3575                         int64_t msg_ref = 0;
3576                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3577                         msg_ref = tag_ptr(msg_var.inner, false);
3578                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
3579                 }
3580                 case LDKMessageSendEvent_SendFundingCreated: {
3581                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3582                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
3583                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
3584                         int64_t msg_ref = 0;
3585                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3586                         msg_ref = tag_ptr(msg_var.inner, false);
3587                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
3588                 }
3589                 case LDKMessageSendEvent_SendFundingSigned: {
3590                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3591                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
3592                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
3593                         int64_t msg_ref = 0;
3594                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3595                         msg_ref = tag_ptr(msg_var.inner, false);
3596                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
3597                 }
3598                 case LDKMessageSendEvent_SendChannelReady: {
3599                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3600                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_ready.node_id.compressed_form);
3601                         LDKChannelReady msg_var = obj->send_channel_ready.msg;
3602                         int64_t msg_ref = 0;
3603                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3604                         msg_ref = tag_ptr(msg_var.inner, false);
3605                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReady_class, LDKMessageSendEvent_SendChannelReady_meth, node_id_arr, msg_ref);
3606                 }
3607                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
3608                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3609                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
3610                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
3611                         int64_t msg_ref = 0;
3612                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3613                         msg_ref = tag_ptr(msg_var.inner, false);
3614                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
3615                 }
3616                 case LDKMessageSendEvent_UpdateHTLCs: {
3617                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3618                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
3619                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
3620                         int64_t updates_ref = 0;
3621                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
3622                         updates_ref = tag_ptr(updates_var.inner, false);
3623                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
3624                 }
3625                 case LDKMessageSendEvent_SendRevokeAndACK: {
3626                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3627                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
3628                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
3629                         int64_t msg_ref = 0;
3630                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3631                         msg_ref = tag_ptr(msg_var.inner, false);
3632                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
3633                 }
3634                 case LDKMessageSendEvent_SendClosingSigned: {
3635                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3636                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
3637                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
3638                         int64_t msg_ref = 0;
3639                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3640                         msg_ref = tag_ptr(msg_var.inner, false);
3641                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
3642                 }
3643                 case LDKMessageSendEvent_SendShutdown: {
3644                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3645                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
3646                         LDKShutdown msg_var = obj->send_shutdown.msg;
3647                         int64_t msg_ref = 0;
3648                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3649                         msg_ref = tag_ptr(msg_var.inner, false);
3650                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
3651                 }
3652                 case LDKMessageSendEvent_SendChannelReestablish: {
3653                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3654                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
3655                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
3656                         int64_t msg_ref = 0;
3657                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3658                         msg_ref = tag_ptr(msg_var.inner, false);
3659                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
3660                 }
3661                 case LDKMessageSendEvent_SendChannelAnnouncement: {
3662                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3663                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_announcement.node_id.compressed_form);
3664                         LDKChannelAnnouncement msg_var = obj->send_channel_announcement.msg;
3665                         int64_t msg_ref = 0;
3666                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3667                         msg_ref = tag_ptr(msg_var.inner, false);
3668                         LDKChannelUpdate update_msg_var = obj->send_channel_announcement.update_msg;
3669                         int64_t update_msg_ref = 0;
3670                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
3671                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
3672                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelAnnouncement_class, LDKMessageSendEvent_SendChannelAnnouncement_meth, node_id_arr, msg_ref, update_msg_ref);
3673                 }
3674                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
3675                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
3676                         int64_t msg_ref = 0;
3677                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3678                         msg_ref = tag_ptr(msg_var.inner, false);
3679                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
3680                         int64_t update_msg_ref = 0;
3681                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
3682                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
3683                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
3684                 }
3685                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
3686                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
3687                         int64_t msg_ref = 0;
3688                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3689                         msg_ref = tag_ptr(msg_var.inner, false);
3690                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
3691                 }
3692                 case LDKMessageSendEvent_SendChannelUpdate: {
3693                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3694                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
3695                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
3696                         int64_t msg_ref = 0;
3697                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3698                         msg_ref = tag_ptr(msg_var.inner, false);
3699                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
3700                 }
3701                 case LDKMessageSendEvent_HandleError: {
3702                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3703                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
3704                         int64_t action_ref = tag_ptr(&obj->handle_error.action, false);
3705                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
3706                 }
3707                 case LDKMessageSendEvent_SendChannelRangeQuery: {
3708                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3709                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
3710                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
3711                         int64_t msg_ref = 0;
3712                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3713                         msg_ref = tag_ptr(msg_var.inner, false);
3714                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
3715                 }
3716                 case LDKMessageSendEvent_SendShortIdsQuery: {
3717                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3718                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
3719                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
3720                         int64_t msg_ref = 0;
3721                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3722                         msg_ref = tag_ptr(msg_var.inner, false);
3723                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
3724                 }
3725                 case LDKMessageSendEvent_SendReplyChannelRange: {
3726                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3727                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
3728                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
3729                         int64_t msg_ref = 0;
3730                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3731                         msg_ref = tag_ptr(msg_var.inner, false);
3732                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
3733                 }
3734                 case LDKMessageSendEvent_SendGossipTimestampFilter: {
3735                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3736                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_gossip_timestamp_filter.node_id.compressed_form);
3737                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
3738                         int64_t msg_ref = 0;
3739                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3740                         msg_ref = tag_ptr(msg_var.inner, false);
3741                         return (*env)->NewObject(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, LDKMessageSendEvent_SendGossipTimestampFilter_meth, node_id_arr, msg_ref);
3742                 }
3743                 default: abort();
3744         }
3745 }
3746 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
3747         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
3748         for (size_t i = 0; i < ret.datalen; i++) {
3749                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
3750         }
3751         return ret;
3752 }
3753 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3754 CHECK(owner->result_ok);
3755         return TxOut_clone(&*owner->contents.result);
3756 }
3757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3758         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(owner);
3759         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
3760         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
3761         return tag_ptr(ret_ref, true);
3762 }
3763
3764 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3765 CHECK(!owner->result_ok);
3766         return AccessError_clone(&*owner->contents.err);
3767 }
3768 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3769         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(owner);
3770         jclass ret_conv = LDKAccessError_to_java(env, CResult_TxOutAccessErrorZ_get_err(owner_conv));
3771         return ret_conv;
3772 }
3773
3774 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3775         return owner->a;
3776 }
3777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3778         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
3779         int64_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
3780         return ret_conv;
3781 }
3782
3783 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3784         return owner->b;
3785 }
3786 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3787         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
3788         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
3789         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3790         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3791         return ret_arr;
3792 }
3793
3794 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
3795         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
3796         for (size_t i = 0; i < ret.datalen; i++) {
3797                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
3798         }
3799         return ret;
3800 }
3801 static inline LDKCVec_TxidZ CVec_TxidZ_clone(const LDKCVec_TxidZ *orig) {
3802         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
3803         for (size_t i = 0; i < ret.datalen; i++) {
3804                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
3805         }
3806         return ret;
3807 }
3808 static inline void CResult_NoneChannelMonitorUpdateErrZ_get_ok(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
3809 CHECK(owner->result_ok);
3810         return *owner->contents.result;
3811 }
3812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3813         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)untag_ptr(owner);
3814         CResult_NoneChannelMonitorUpdateErrZ_get_ok(owner_conv);
3815 }
3816
3817 static inline enum LDKChannelMonitorUpdateErr CResult_NoneChannelMonitorUpdateErrZ_get_err(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR owner){
3818 CHECK(!owner->result_ok);
3819         return ChannelMonitorUpdateErr_clone(&*owner->contents.err);
3820 }
3821 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3822         LDKCResult_NoneChannelMonitorUpdateErrZ* owner_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)untag_ptr(owner);
3823         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, CResult_NoneChannelMonitorUpdateErrZ_get_err(owner_conv));
3824         return ret_conv;
3825 }
3826
3827 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
3828 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
3829 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
3830 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
3831 static jclass LDKMonitorEvent_UpdateCompleted_class = NULL;
3832 static jmethodID LDKMonitorEvent_UpdateCompleted_meth = NULL;
3833 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
3834 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
3835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
3836         LDKMonitorEvent_HTLCEvent_class =
3837                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent"));
3838         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
3839         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
3840         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
3841         LDKMonitorEvent_CommitmentTxConfirmed_class =
3842                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed"));
3843         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
3844         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
3845         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
3846         LDKMonitorEvent_UpdateCompleted_class =
3847                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateCompleted"));
3848         CHECK(LDKMonitorEvent_UpdateCompleted_class != NULL);
3849         LDKMonitorEvent_UpdateCompleted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateCompleted_class, "<init>", "(JJ)V");
3850         CHECK(LDKMonitorEvent_UpdateCompleted_meth != NULL);
3851         LDKMonitorEvent_UpdateFailed_class =
3852                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed"));
3853         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
3854         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
3855         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
3856 }
3857 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3858         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
3859         switch(obj->tag) {
3860                 case LDKMonitorEvent_HTLCEvent: {
3861                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
3862                         int64_t htlc_event_ref = 0;
3863                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
3864                         htlc_event_ref = tag_ptr(htlc_event_var.inner, false);
3865                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
3866                 }
3867                 case LDKMonitorEvent_CommitmentTxConfirmed: {
3868                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
3869                         int64_t commitment_tx_confirmed_ref = 0;
3870                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
3871                         commitment_tx_confirmed_ref = tag_ptr(commitment_tx_confirmed_var.inner, false);
3872                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
3873                 }
3874                 case LDKMonitorEvent_UpdateCompleted: {
3875                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
3876                         int64_t funding_txo_ref = 0;
3877                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
3878                         funding_txo_ref = tag_ptr(funding_txo_var.inner, false);
3879                         int64_t monitor_update_id_conv = obj->update_completed.monitor_update_id;
3880                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateCompleted_class, LDKMonitorEvent_UpdateCompleted_meth, funding_txo_ref, monitor_update_id_conv);
3881                 }
3882                 case LDKMonitorEvent_UpdateFailed: {
3883                         LDKOutPoint update_failed_var = obj->update_failed;
3884                         int64_t update_failed_ref = 0;
3885                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
3886                         update_failed_ref = tag_ptr(update_failed_var.inner, false);
3887                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
3888                 }
3889                 default: abort();
3890         }
3891 }
3892 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
3893         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
3894         for (size_t i = 0; i < ret.datalen; i++) {
3895                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
3896         }
3897         return ret;
3898 }
3899 static inline struct LDKOutPoint C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3900         LDKOutPoint ret = owner->a;
3901         ret.is_owned = false;
3902         return ret;
3903 }
3904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3905         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
3906         LDKOutPoint ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(owner_conv);
3907         int64_t ret_ref = 0;
3908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3909         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3910         return ret_ref;
3911 }
3912
3913 static inline struct LDKCVec_MonitorEventZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3914         return CVec_MonitorEventZ_clone(&owner->b);
3915 }
3916 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3917         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
3918         LDKCVec_MonitorEventZ ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(owner_conv);
3919         int64_tArray ret_arr = NULL;
3920         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
3921         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
3922         for (size_t o = 0; o < ret_var.datalen; o++) {
3923                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
3924                 *ret_conv_14_copy = ret_var.data[o];
3925                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
3926                 ret_arr_ptr[o] = ret_conv_14_ref;
3927         }
3928         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
3929         FREE(ret_var.data);
3930         return ret_arr;
3931 }
3932
3933 static inline struct LDKPublicKey C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3934         return owner->c;
3935 }
3936 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
3937         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
3938         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3939         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(owner_conv).compressed_form);
3940         return ret_arr;
3941 }
3942
3943 static inline LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_clone(const LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ *orig) {
3944         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) * orig->datalen, "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ clone bytes"), .datalen = orig->datalen };
3945         for (size_t i = 0; i < ret.datalen; i++) {
3946                 ret.data[i] = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(&orig->data[i]);
3947         }
3948         return ret;
3949 }
3950 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3951         LDKFixedPenaltyScorer ret = *owner->contents.result;
3952         ret.is_owned = false;
3953         return ret;
3954 }
3955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3956         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
3957         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
3958         int64_t ret_ref = 0;
3959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3960         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3961         return ret_ref;
3962 }
3963
3964 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
3965         LDKDecodeError ret = *owner->contents.err;
3966         ret.is_owned = false;
3967         return ret;
3968 }
3969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3970         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
3971         LDKDecodeError ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
3972         int64_t ret_ref = 0;
3973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3974         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
3975         return ret_ref;
3976 }
3977
3978 static inline uint64_t C2Tuple_u64u64Z_get_a(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3979         return owner->a;
3980 }
3981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3982         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
3983         int64_t ret_conv = C2Tuple_u64u64Z_get_a(owner_conv);
3984         return ret_conv;
3985 }
3986
3987 static inline uint64_t C2Tuple_u64u64Z_get_b(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
3988         return owner->b;
3989 }
3990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3991         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
3992         int64_t ret_conv = C2Tuple_u64u64Z_get_b(owner_conv);
3993         return ret_conv;
3994 }
3995
3996 static jclass LDKCOption_C2Tuple_u64u64ZZ_Some_class = NULL;
3997 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_Some_meth = NULL;
3998 static jclass LDKCOption_C2Tuple_u64u64ZZ_None_class = NULL;
3999 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_None_meth = NULL;
4000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1u64u64ZZ_init (JNIEnv *env, jclass clz) {
4001         LDKCOption_C2Tuple_u64u64ZZ_Some_class =
4002                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$Some"));
4003         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_class != NULL);
4004         LDKCOption_C2Tuple_u64u64ZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, "<init>", "(J)V");
4005         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_meth != NULL);
4006         LDKCOption_C2Tuple_u64u64ZZ_None_class =
4007                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$None"));
4008         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_class != NULL);
4009         LDKCOption_C2Tuple_u64u64ZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, "<init>", "()V");
4010         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_meth != NULL);
4011 }
4012 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1u64u64ZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4013         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(ptr);
4014         switch(obj->tag) {
4015                 case LDKCOption_C2Tuple_u64u64ZZ_Some: {
4016                         LDKC2Tuple_u64u64Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
4017                         *some_conv = obj->some;
4018                         *some_conv = C2Tuple_u64u64Z_clone(some_conv);
4019                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, LDKCOption_C2Tuple_u64u64ZZ_Some_meth, tag_ptr(some_conv, true));
4020                 }
4021                 case LDKCOption_C2Tuple_u64u64ZZ_None: {
4022                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, LDKCOption_C2Tuple_u64u64ZZ_None_meth);
4023                 }
4024                 default: abort();
4025         }
4026 }
4027 static inline LDKCVec_NodeIdZ CVec_NodeIdZ_clone(const LDKCVec_NodeIdZ *orig) {
4028         LDKCVec_NodeIdZ ret = { .data = MALLOC(sizeof(LDKNodeId) * orig->datalen, "LDKCVec_NodeIdZ clone bytes"), .datalen = orig->datalen };
4029         for (size_t i = 0; i < ret.datalen; i++) {
4030                 ret.data[i] = NodeId_clone(&orig->data[i]);
4031         }
4032         return ret;
4033 }
4034 typedef struct LDKLogger_JCalls {
4035         atomic_size_t refcnt;
4036         JavaVM *vm;
4037         jweak o;
4038         jmethodID log_meth;
4039 } LDKLogger_JCalls;
4040 static void LDKLogger_JCalls_free(void* this_arg) {
4041         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4042         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4043                 JNIEnv *env;
4044                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4045                 if (get_jenv_res == JNI_EDETACHED) {
4046                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4047                 } else {
4048                         DO_ASSERT(get_jenv_res == JNI_OK);
4049                 }
4050                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4051                 if (get_jenv_res == JNI_EDETACHED) {
4052                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4053                 }
4054                 FREE(j_calls);
4055         }
4056 }
4057 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
4058         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4059         JNIEnv *env;
4060         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4061         if (get_jenv_res == JNI_EDETACHED) {
4062                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4063         } else {
4064                 DO_ASSERT(get_jenv_res == JNI_OK);
4065         }
4066         LDKRecord record_var = *record;
4067         int64_t record_ref = 0;
4068         record_var = Record_clone(&record_var);
4069         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
4070         record_ref = tag_ptr(record_var.inner, record_var.is_owned);
4071         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4072         CHECK(obj != NULL);
4073         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
4074         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4075                 (*env)->ExceptionDescribe(env);
4076                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
4077         }
4078         if (get_jenv_res == JNI_EDETACHED) {
4079                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4080         }
4081 }
4082 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4083         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4084         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4085 }
4086 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
4087         jclass c = (*env)->GetObjectClass(env, o);
4088         CHECK(c != NULL);
4089         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4090         atomic_init(&calls->refcnt, 1);
4091         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4092         calls->o = (*env)->NewWeakGlobalRef(env, o);
4093         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
4094         CHECK(calls->log_meth != NULL);
4095
4096         LDKLogger ret = {
4097                 .this_arg = (void*) calls,
4098                 .log = log_LDKLogger_jcall,
4099                 .free = LDKLogger_JCalls_free,
4100         };
4101         return ret;
4102 }
4103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
4104         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4105         *res_ptr = LDKLogger_init(env, clz, o);
4106         return tag_ptr(res_ptr, true);
4107 }
4108 static inline struct LDKProbabilisticScorer CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
4109         LDKProbabilisticScorer ret = *owner->contents.result;
4110         ret.is_owned = false;
4111         return ret;
4112 }
4113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4114         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
4115         LDKProbabilisticScorer ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
4116         int64_t ret_ref = 0;
4117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4118         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4119         return ret_ref;
4120 }
4121
4122 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
4123         LDKDecodeError ret = *owner->contents.err;
4124         ret.is_owned = false;
4125         return ret;
4126 }
4127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4128         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
4129         LDKDecodeError ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
4130         int64_t ret_ref = 0;
4131         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4132         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4133         return ret_ref;
4134 }
4135
4136 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
4137         LDKInitFeatures ret = *owner->contents.result;
4138         ret.is_owned = false;
4139         return ret;
4140 }
4141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4142         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
4143         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
4144         int64_t ret_ref = 0;
4145         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4146         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4147         return ret_ref;
4148 }
4149
4150 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
4151         LDKDecodeError ret = *owner->contents.err;
4152         ret.is_owned = false;
4153         return ret;
4154 }
4155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4156         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
4157         LDKDecodeError ret_var = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
4158         int64_t ret_ref = 0;
4159         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4160         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4161         return ret_ref;
4162 }
4163
4164 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
4165         LDKChannelFeatures ret = *owner->contents.result;
4166         ret.is_owned = false;
4167         return ret;
4168 }
4169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4170         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
4171         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
4172         int64_t ret_ref = 0;
4173         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4174         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4175         return ret_ref;
4176 }
4177
4178 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
4179         LDKDecodeError ret = *owner->contents.err;
4180         ret.is_owned = false;
4181         return ret;
4182 }
4183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4184         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
4185         LDKDecodeError ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
4186         int64_t ret_ref = 0;
4187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4188         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4189         return ret_ref;
4190 }
4191
4192 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4193         LDKNodeFeatures ret = *owner->contents.result;
4194         ret.is_owned = false;
4195         return ret;
4196 }
4197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4198         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
4199         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
4200         int64_t ret_ref = 0;
4201         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4202         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4203         return ret_ref;
4204 }
4205
4206 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4207         LDKDecodeError ret = *owner->contents.err;
4208         ret.is_owned = false;
4209         return ret;
4210 }
4211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4212         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
4213         LDKDecodeError ret_var = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
4214         int64_t ret_ref = 0;
4215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4216         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4217         return ret_ref;
4218 }
4219
4220 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
4221         LDKInvoiceFeatures ret = *owner->contents.result;
4222         ret.is_owned = false;
4223         return ret;
4224 }
4225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4226         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
4227         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
4228         int64_t ret_ref = 0;
4229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4230         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4231         return ret_ref;
4232 }
4233
4234 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
4235         LDKDecodeError ret = *owner->contents.err;
4236         ret.is_owned = false;
4237         return ret;
4238 }
4239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4240         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
4241         LDKDecodeError ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
4242         int64_t ret_ref = 0;
4243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4244         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4245         return ret_ref;
4246 }
4247
4248 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4249         LDKChannelTypeFeatures ret = *owner->contents.result;
4250         ret.is_owned = false;
4251         return ret;
4252 }
4253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4254         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
4255         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
4256         int64_t ret_ref = 0;
4257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4258         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4259         return ret_ref;
4260 }
4261
4262 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4263         LDKDecodeError ret = *owner->contents.err;
4264         ret.is_owned = false;
4265         return ret;
4266 }
4267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4268         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
4269         LDKDecodeError ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
4270         int64_t ret_ref = 0;
4271         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4272         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4273         return ret_ref;
4274 }
4275
4276 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
4277         LDKNodeId ret = *owner->contents.result;
4278         ret.is_owned = false;
4279         return ret;
4280 }
4281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4282         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
4283         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
4284         int64_t ret_ref = 0;
4285         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4286         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4287         return ret_ref;
4288 }
4289
4290 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
4291         LDKDecodeError ret = *owner->contents.err;
4292         ret.is_owned = false;
4293         return ret;
4294 }
4295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4296         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
4297         LDKDecodeError ret_var = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
4298         int64_t ret_ref = 0;
4299         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4300         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4301         return ret_ref;
4302 }
4303
4304 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
4305 CHECK(owner->result_ok);
4306         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
4307 }
4308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4309         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
4310         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
4311         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
4312         int64_t ret_ref = tag_ptr(ret_copy, true);
4313         return ret_ref;
4314 }
4315
4316 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
4317         LDKDecodeError ret = *owner->contents.err;
4318         ret.is_owned = false;
4319         return ret;
4320 }
4321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4322         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
4323         LDKDecodeError ret_var = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
4324         int64_t ret_ref = 0;
4325         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4326         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4327         return ret_ref;
4328 }
4329
4330 typedef struct LDKAccess_JCalls {
4331         atomic_size_t refcnt;
4332         JavaVM *vm;
4333         jweak o;
4334         jmethodID get_utxo_meth;
4335 } LDKAccess_JCalls;
4336 static void LDKAccess_JCalls_free(void* this_arg) {
4337         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4338         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4339                 JNIEnv *env;
4340                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4341                 if (get_jenv_res == JNI_EDETACHED) {
4342                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4343                 } else {
4344                         DO_ASSERT(get_jenv_res == JNI_OK);
4345                 }
4346                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4347                 if (get_jenv_res == JNI_EDETACHED) {
4348                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4349                 }
4350                 FREE(j_calls);
4351         }
4352 }
4353 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4354         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4355         JNIEnv *env;
4356         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4357         if (get_jenv_res == JNI_EDETACHED) {
4358                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4359         } else {
4360                 DO_ASSERT(get_jenv_res == JNI_OK);
4361         }
4362         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
4363         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
4364         int64_t short_channel_id_conv = short_channel_id;
4365         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4366         CHECK(obj != NULL);
4367         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id_conv);
4368         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4369                 (*env)->ExceptionDescribe(env);
4370                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
4371         }
4372         void* ret_ptr = untag_ptr(ret);
4373         CHECK_ACCESS(ret_ptr);
4374         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
4375         FREE(untag_ptr(ret));
4376         if (get_jenv_res == JNI_EDETACHED) {
4377                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4378         }
4379         return ret_conv;
4380 }
4381 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
4382         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
4383         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4384 }
4385 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
4386         jclass c = (*env)->GetObjectClass(env, o);
4387         CHECK(c != NULL);
4388         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
4389         atomic_init(&calls->refcnt, 1);
4390         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4391         calls->o = (*env)->NewWeakGlobalRef(env, o);
4392         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
4393         CHECK(calls->get_utxo_meth != NULL);
4394
4395         LDKAccess ret = {
4396                 .this_arg = (void*) calls,
4397                 .get_utxo = get_utxo_LDKAccess_jcall,
4398                 .free = LDKAccess_JCalls_free,
4399         };
4400         return ret;
4401 }
4402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
4403         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
4404         *res_ptr = LDKAccess_init(env, clz, o);
4405         return tag_ptr(res_ptr, true);
4406 }
4407 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) {
4408         void* this_arg_ptr = untag_ptr(this_arg);
4409         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4410         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
4411         unsigned char genesis_hash_arr[32];
4412         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
4413         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
4414         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
4415         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4416         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4417         return tag_ptr(ret_conv, true);
4418 }
4419
4420 static jclass LDKCOption_AccessZ_Some_class = NULL;
4421 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
4422 static jclass LDKCOption_AccessZ_None_class = NULL;
4423 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
4424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
4425         LDKCOption_AccessZ_Some_class =
4426                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$Some"));
4427         CHECK(LDKCOption_AccessZ_Some_class != NULL);
4428         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
4429         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
4430         LDKCOption_AccessZ_None_class =
4431                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$None"));
4432         CHECK(LDKCOption_AccessZ_None_class != NULL);
4433         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
4434         CHECK(LDKCOption_AccessZ_None_meth != NULL);
4435 }
4436 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4437         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)untag_ptr(ptr);
4438         switch(obj->tag) {
4439                 case LDKCOption_AccessZ_Some: {
4440                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
4441                         *some_ret = obj->some;
4442                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
4443                         if ((*some_ret).free == LDKAccess_JCalls_free) {
4444                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
4445                                 LDKAccess_JCalls_cloned(&(*some_ret));
4446                         }
4447                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, tag_ptr(some_ret, true));
4448                 }
4449                 case LDKCOption_AccessZ_None: {
4450                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
4451                 }
4452                 default: abort();
4453         }
4454 }
4455 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
4456 CHECK(owner->result_ok);
4457         return *owner->contents.result;
4458 }
4459 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4460         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
4461         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
4462         return ret_conv;
4463 }
4464
4465 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
4466         LDKLightningError ret = *owner->contents.err;
4467         ret.is_owned = false;
4468         return ret;
4469 }
4470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4471         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
4472         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
4473         int64_t ret_ref = 0;
4474         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4475         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4476         return ret_ref;
4477 }
4478
4479 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4480         LDKChannelAnnouncement ret = owner->a;
4481         ret.is_owned = false;
4482         return ret;
4483 }
4484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4485         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
4486         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
4487         int64_t ret_ref = 0;
4488         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4489         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4490         return ret_ref;
4491 }
4492
4493 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4494         LDKChannelUpdate ret = owner->b;
4495         ret.is_owned = false;
4496         return ret;
4497 }
4498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4499         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
4500         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
4501         int64_t ret_ref = 0;
4502         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4503         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4504         return ret_ref;
4505 }
4506
4507 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4508         LDKChannelUpdate ret = owner->c;
4509         ret.is_owned = false;
4510         return ret;
4511 }
4512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
4513         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
4514         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
4515         int64_t ret_ref = 0;
4516         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4517         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4518         return ret_ref;
4519 }
4520
4521 static jclass LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class = NULL;
4522 static jmethodID LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth = NULL;
4523 static jclass LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class = NULL;
4524 static jmethodID LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth = NULL;
4525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_init (JNIEnv *env, jclass clz) {
4526         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class =
4527                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ$Some"));
4528         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class != NULL);
4529         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class, "<init>", "(J)V");
4530         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth != NULL);
4531         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class =
4532                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ$None"));
4533         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class != NULL);
4534         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class, "<init>", "()V");
4535         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth != NULL);
4536 }
4537 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4538         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *obj = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(ptr);
4539         switch(obj->tag) {
4540                 case LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some: {
4541                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* some_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4542                         *some_conv = obj->some;
4543                         *some_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(some_conv);
4544                         return (*env)->NewObject(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth, tag_ptr(some_conv, true));
4545                 }
4546                 case LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None: {
4547                         return (*env)->NewObject(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth);
4548                 }
4549                 default: abort();
4550         }
4551 }
4552 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
4553 CHECK(owner->result_ok);
4554         return *owner->contents.result;
4555 }
4556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4557         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
4558         CResult_NoneLightningErrorZ_get_ok(owner_conv);
4559 }
4560
4561 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
4562         LDKLightningError ret = *owner->contents.err;
4563         ret.is_owned = false;
4564         return ret;
4565 }
4566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4567         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
4568         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
4569         int64_t ret_ref = 0;
4570         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4571         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4572         return ret_ref;
4573 }
4574
4575 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
4576         LDKChannelUpdateInfo ret = *owner->contents.result;
4577         ret.is_owned = false;
4578         return ret;
4579 }
4580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4581         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
4582         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
4583         int64_t ret_ref = 0;
4584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4585         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4586         return ret_ref;
4587 }
4588
4589 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
4590         LDKDecodeError ret = *owner->contents.err;
4591         ret.is_owned = false;
4592         return ret;
4593 }
4594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4595         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
4596         LDKDecodeError ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
4597         int64_t ret_ref = 0;
4598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4599         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4600         return ret_ref;
4601 }
4602
4603 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4604         LDKChannelInfo ret = *owner->contents.result;
4605         ret.is_owned = false;
4606         return ret;
4607 }
4608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4609         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
4610         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
4611         int64_t ret_ref = 0;
4612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4613         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4614         return ret_ref;
4615 }
4616
4617 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4618         LDKDecodeError ret = *owner->contents.err;
4619         ret.is_owned = false;
4620         return ret;
4621 }
4622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4623         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
4624         LDKDecodeError ret_var = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
4625         int64_t ret_ref = 0;
4626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4627         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4628         return ret_ref;
4629 }
4630
4631 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4632         LDKRoutingFees ret = *owner->contents.result;
4633         ret.is_owned = false;
4634         return ret;
4635 }
4636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4637         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
4638         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
4639         int64_t ret_ref = 0;
4640         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4641         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4642         return ret_ref;
4643 }
4644
4645 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4646         LDKDecodeError ret = *owner->contents.err;
4647         ret.is_owned = false;
4648         return ret;
4649 }
4650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4651         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
4652         LDKDecodeError ret_var = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
4653         int64_t ret_ref = 0;
4654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4655         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4656         return ret_ref;
4657 }
4658
4659 static jclass LDKNetAddress_IPv4_class = NULL;
4660 static jmethodID LDKNetAddress_IPv4_meth = NULL;
4661 static jclass LDKNetAddress_IPv6_class = NULL;
4662 static jmethodID LDKNetAddress_IPv6_meth = NULL;
4663 static jclass LDKNetAddress_OnionV2_class = NULL;
4664 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
4665 static jclass LDKNetAddress_OnionV3_class = NULL;
4666 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
4667 static jclass LDKNetAddress_Hostname_class = NULL;
4668 static jmethodID LDKNetAddress_Hostname_meth = NULL;
4669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
4670         LDKNetAddress_IPv4_class =
4671                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
4672         CHECK(LDKNetAddress_IPv4_class != NULL);
4673         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
4674         CHECK(LDKNetAddress_IPv4_meth != NULL);
4675         LDKNetAddress_IPv6_class =
4676                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
4677         CHECK(LDKNetAddress_IPv6_class != NULL);
4678         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
4679         CHECK(LDKNetAddress_IPv6_meth != NULL);
4680         LDKNetAddress_OnionV2_class =
4681                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
4682         CHECK(LDKNetAddress_OnionV2_class != NULL);
4683         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
4684         CHECK(LDKNetAddress_OnionV2_meth != NULL);
4685         LDKNetAddress_OnionV3_class =
4686                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
4687         CHECK(LDKNetAddress_OnionV3_class != NULL);
4688         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
4689         CHECK(LDKNetAddress_OnionV3_meth != NULL);
4690         LDKNetAddress_Hostname_class =
4691                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$Hostname"));
4692         CHECK(LDKNetAddress_Hostname_class != NULL);
4693         LDKNetAddress_Hostname_meth = (*env)->GetMethodID(env, LDKNetAddress_Hostname_class, "<init>", "(JS)V");
4694         CHECK(LDKNetAddress_Hostname_meth != NULL);
4695 }
4696 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4697         LDKNetAddress *obj = (LDKNetAddress*)untag_ptr(ptr);
4698         switch(obj->tag) {
4699                 case LDKNetAddress_IPv4: {
4700                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
4701                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
4702                         int16_t port_conv = obj->i_pv4.port;
4703                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, port_conv);
4704                 }
4705                 case LDKNetAddress_IPv6: {
4706                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
4707                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
4708                         int16_t port_conv = obj->i_pv6.port;
4709                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, port_conv);
4710                 }
4711                 case LDKNetAddress_OnionV2: {
4712                         int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
4713                         (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
4714                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
4715                 }
4716                 case LDKNetAddress_OnionV3: {
4717                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
4718                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
4719                         int16_t checksum_conv = obj->onion_v3.checksum;
4720                         int8_t version_conv = obj->onion_v3.version;
4721                         int16_t port_conv = obj->onion_v3.port;
4722                         return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, checksum_conv, version_conv, port_conv);
4723                 }
4724                 case LDKNetAddress_Hostname: {
4725                         LDKHostname hostname_var = obj->hostname.hostname;
4726                         int64_t hostname_ref = 0;
4727                         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_var);
4728                         hostname_ref = tag_ptr(hostname_var.inner, false);
4729                         int16_t port_conv = obj->hostname.port;
4730                         return (*env)->NewObject(env, LDKNetAddress_Hostname_class, LDKNetAddress_Hostname_meth, hostname_ref, port_conv);
4731                 }
4732                 default: abort();
4733         }
4734 }
4735 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
4736         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
4737         for (size_t i = 0; i < ret.datalen; i++) {
4738                 ret.data[i] = NetAddress_clone(&orig->data[i]);
4739         }
4740         return ret;
4741 }
4742 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4743         LDKNodeAnnouncementInfo ret = *owner->contents.result;
4744         ret.is_owned = false;
4745         return ret;
4746 }
4747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4748         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
4749         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
4750         int64_t ret_ref = 0;
4751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4752         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4753         return ret_ref;
4754 }
4755
4756 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4757         LDKDecodeError ret = *owner->contents.err;
4758         ret.is_owned = false;
4759         return ret;
4760 }
4761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4762         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
4763         LDKDecodeError ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
4764         int64_t ret_ref = 0;
4765         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4766         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4767         return ret_ref;
4768 }
4769
4770 static inline struct LDKNodeAlias CResult_NodeAliasDecodeErrorZ_get_ok(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4771         LDKNodeAlias ret = *owner->contents.result;
4772         ret.is_owned = false;
4773         return ret;
4774 }
4775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4776         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
4777         LDKNodeAlias ret_var = CResult_NodeAliasDecodeErrorZ_get_ok(owner_conv);
4778         int64_t ret_ref = 0;
4779         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4780         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4781         return ret_ref;
4782 }
4783
4784 static inline struct LDKDecodeError CResult_NodeAliasDecodeErrorZ_get_err(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4785         LDKDecodeError ret = *owner->contents.err;
4786         ret.is_owned = false;
4787         return ret;
4788 }
4789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4790         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
4791         LDKDecodeError ret_var = CResult_NodeAliasDecodeErrorZ_get_err(owner_conv);
4792         int64_t ret_ref = 0;
4793         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4794         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4795         return ret_ref;
4796 }
4797
4798 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4799         LDKNodeInfo ret = *owner->contents.result;
4800         ret.is_owned = false;
4801         return ret;
4802 }
4803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4804         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
4805         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
4806         int64_t ret_ref = 0;
4807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4808         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4809         return ret_ref;
4810 }
4811
4812 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4813         LDKDecodeError ret = *owner->contents.err;
4814         ret.is_owned = false;
4815         return ret;
4816 }
4817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4818         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
4819         LDKDecodeError ret_var = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
4820         int64_t ret_ref = 0;
4821         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4822         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4823         return ret_ref;
4824 }
4825
4826 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4827         LDKNetworkGraph ret = *owner->contents.result;
4828         ret.is_owned = false;
4829         return ret;
4830 }
4831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4832         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
4833         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
4834         int64_t ret_ref = 0;
4835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4836         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4837         return ret_ref;
4838 }
4839
4840 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4841         LDKDecodeError ret = *owner->contents.err;
4842         ret.is_owned = false;
4843         return ret;
4844 }
4845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4846         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
4847         LDKDecodeError ret_var = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
4848         int64_t ret_ref = 0;
4849         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4850         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4851         return ret_ref;
4852 }
4853
4854 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
4855 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
4856 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
4857 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
4858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
4859         LDKCOption_CVec_NetAddressZZ_Some_class =
4860                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
4861         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
4862         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
4863         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
4864         LDKCOption_CVec_NetAddressZZ_None_class =
4865                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
4866         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
4867         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
4868         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
4869 }
4870 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4871         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(ptr);
4872         switch(obj->tag) {
4873                 case LDKCOption_CVec_NetAddressZZ_Some: {
4874                         LDKCVec_NetAddressZ some_var = obj->some;
4875                         int64_tArray some_arr = NULL;
4876                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
4877                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
4878                         for (size_t m = 0; m < some_var.datalen; m++) {
4879                                 int64_t some_conv_12_ref = tag_ptr(&some_var.data[m], false);
4880                                 some_arr_ptr[m] = some_conv_12_ref;
4881                         }
4882                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
4883                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
4884                 }
4885                 case LDKCOption_CVec_NetAddressZZ_None: {
4886                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
4887                 }
4888                 default: abort();
4889         }
4890 }
4891 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4892         LDKDelayedPaymentOutputDescriptor ret = *owner->contents.result;
4893         ret.is_owned = false;
4894         return ret;
4895 }
4896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4897         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4898         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4899         int64_t ret_ref = 0;
4900         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4901         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4902         return ret_ref;
4903 }
4904
4905 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4906         LDKDecodeError ret = *owner->contents.err;
4907         ret.is_owned = false;
4908         return ret;
4909 }
4910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4911         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4912         LDKDecodeError ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4913         int64_t ret_ref = 0;
4914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4915         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4916         return ret_ref;
4917 }
4918
4919 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4920         LDKStaticPaymentOutputDescriptor ret = *owner->contents.result;
4921         ret.is_owned = false;
4922         return ret;
4923 }
4924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4925         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4926         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4927         int64_t ret_ref = 0;
4928         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4929         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4930         return ret_ref;
4931 }
4932
4933 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4934         LDKDecodeError ret = *owner->contents.err;
4935         ret.is_owned = false;
4936         return ret;
4937 }
4938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4939         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4940         LDKDecodeError ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4941         int64_t ret_ref = 0;
4942         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4943         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4944         return ret_ref;
4945 }
4946
4947 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4948 CHECK(owner->result_ok);
4949         return SpendableOutputDescriptor_clone(&*owner->contents.result);
4950 }
4951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4952         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4953         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
4954         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
4955         int64_t ret_ref = tag_ptr(ret_copy, true);
4956         return ret_ref;
4957 }
4958
4959 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
4960         LDKDecodeError ret = *owner->contents.err;
4961         ret.is_owned = false;
4962         return ret;
4963 }
4964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4965         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
4966         LDKDecodeError ret_var = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
4967         int64_t ret_ref = 0;
4968         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4969         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4970         return ret_ref;
4971 }
4972
4973 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
4974         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
4975         for (size_t i = 0; i < ret.datalen; i++) {
4976                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
4977         }
4978         return ret;
4979 }
4980 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
4981         return owner->a;
4982 }
4983 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4984         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(owner);
4985         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
4986         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form);
4987         return ret_arr;
4988 }
4989
4990 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
4991         return owner->b;
4992 }
4993 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4994         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(owner);
4995         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
4996         jobjectArray ret_arr = NULL;
4997         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
4998         ;
4999         for (size_t i = 0; i < ret_var.datalen; i++) {
5000                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
5001                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
5002                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
5003         }
5004         
5005         return ret_arr;
5006 }
5007
5008 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
5009 CHECK(owner->result_ok);
5010         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
5011 }
5012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5013         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(owner);
5014         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
5015         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
5016         return tag_ptr(ret_conv, true);
5017 }
5018
5019 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
5020 CHECK(!owner->result_ok);
5021         return *owner->contents.err;
5022 }
5023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5024         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(owner);
5025         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
5026 }
5027
5028 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
5029 CHECK(owner->result_ok);
5030         return *owner->contents.result;
5031 }
5032 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5033         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(owner);
5034         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5035         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form);
5036         return ret_arr;
5037 }
5038
5039 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
5040 CHECK(!owner->result_ok);
5041         return *owner->contents.err;
5042 }
5043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5044         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(owner);
5045         CResult_SignatureNoneZ_get_err(owner_conv);
5046 }
5047
5048 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
5049         return owner->a;
5050 }
5051 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5052         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(owner);
5053         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5054         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form);
5055         return ret_arr;
5056 }
5057
5058 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
5059         return owner->b;
5060 }
5061 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5062         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(owner);
5063         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5064         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form);
5065         return ret_arr;
5066 }
5067
5068 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
5069 CHECK(owner->result_ok);
5070         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
5071 }
5072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5073         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(owner);
5074         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
5075         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
5076         return tag_ptr(ret_conv, true);
5077 }
5078
5079 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
5080 CHECK(!owner->result_ok);
5081         return *owner->contents.err;
5082 }
5083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5084         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(owner);
5085         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
5086 }
5087
5088 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
5089 CHECK(owner->result_ok);
5090         return *owner->contents.result;
5091 }
5092 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5093         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(owner);
5094         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5095         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes);
5096         return ret_arr;
5097 }
5098
5099 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
5100 CHECK(!owner->result_ok);
5101         return *owner->contents.err;
5102 }
5103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5104         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(owner);
5105         CResult_SecretKeyNoneZ_get_err(owner_conv);
5106 }
5107
5108 static jclass LDKCOption_ScalarZ_Some_class = NULL;
5109 static jmethodID LDKCOption_ScalarZ_Some_meth = NULL;
5110 static jclass LDKCOption_ScalarZ_None_class = NULL;
5111 static jmethodID LDKCOption_ScalarZ_None_meth = NULL;
5112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ScalarZ_init (JNIEnv *env, jclass clz) {
5113         LDKCOption_ScalarZ_Some_class =
5114                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ScalarZ$Some"));
5115         CHECK(LDKCOption_ScalarZ_Some_class != NULL);
5116         LDKCOption_ScalarZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ScalarZ_Some_class, "<init>", "(J)V");
5117         CHECK(LDKCOption_ScalarZ_Some_meth != NULL);
5118         LDKCOption_ScalarZ_None_class =
5119                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ScalarZ$None"));
5120         CHECK(LDKCOption_ScalarZ_None_class != NULL);
5121         LDKCOption_ScalarZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ScalarZ_None_class, "<init>", "()V");
5122         CHECK(LDKCOption_ScalarZ_None_meth != NULL);
5123 }
5124 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ScalarZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5125         LDKCOption_ScalarZ *obj = (LDKCOption_ScalarZ*)untag_ptr(ptr);
5126         switch(obj->tag) {
5127                 case LDKCOption_ScalarZ_Some: {
5128                         LDKBigEndianScalar* some_ref = &obj->some;
5129                         return (*env)->NewObject(env, LDKCOption_ScalarZ_Some_class, LDKCOption_ScalarZ_Some_meth, tag_ptr(some_ref, false));
5130                 }
5131                 case LDKCOption_ScalarZ_None: {
5132                         return (*env)->NewObject(env, LDKCOption_ScalarZ_None_class, LDKCOption_ScalarZ_None_meth);
5133                 }
5134                 default: abort();
5135         }
5136 }
5137 static inline struct LDKThirtyTwoBytes CResult_SharedSecretNoneZ_get_ok(LDKCResult_SharedSecretNoneZ *NONNULL_PTR owner){
5138 CHECK(owner->result_ok);
5139         return ThirtyTwoBytes_clone(&*owner->contents.result);
5140 }
5141 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5142         LDKCResult_SharedSecretNoneZ* owner_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(owner);
5143         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5144         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SharedSecretNoneZ_get_ok(owner_conv).data);
5145         return ret_arr;
5146 }
5147
5148 static inline void CResult_SharedSecretNoneZ_get_err(LDKCResult_SharedSecretNoneZ *NONNULL_PTR owner){
5149 CHECK(!owner->result_ok);
5150         return *owner->contents.err;
5151 }
5152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5153         LDKCResult_SharedSecretNoneZ* owner_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(owner);
5154         CResult_SharedSecretNoneZ_get_err(owner_conv);
5155 }
5156
5157 typedef struct LDKBaseSign_JCalls {
5158         atomic_size_t refcnt;
5159         JavaVM *vm;
5160         jweak o;
5161         jmethodID get_per_commitment_point_meth;
5162         jmethodID release_commitment_secret_meth;
5163         jmethodID validate_holder_commitment_meth;
5164         jmethodID channel_keys_id_meth;
5165         jmethodID sign_counterparty_commitment_meth;
5166         jmethodID validate_counterparty_revocation_meth;
5167         jmethodID sign_holder_commitment_and_htlcs_meth;
5168         jmethodID sign_justice_revoked_output_meth;
5169         jmethodID sign_justice_revoked_htlc_meth;
5170         jmethodID sign_counterparty_htlc_transaction_meth;
5171         jmethodID sign_closing_transaction_meth;
5172         jmethodID sign_channel_announcement_meth;
5173         jmethodID ready_channel_meth;
5174 } LDKBaseSign_JCalls;
5175 static void LDKBaseSign_JCalls_free(void* this_arg) {
5176         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5177         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5178                 JNIEnv *env;
5179                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5180                 if (get_jenv_res == JNI_EDETACHED) {
5181                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5182                 } else {
5183                         DO_ASSERT(get_jenv_res == JNI_OK);
5184                 }
5185                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5186                 if (get_jenv_res == JNI_EDETACHED) {
5187                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5188                 }
5189                 FREE(j_calls);
5190         }
5191 }
5192 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
5193         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5194         JNIEnv *env;
5195         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5196         if (get_jenv_res == JNI_EDETACHED) {
5197                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5198         } else {
5199                 DO_ASSERT(get_jenv_res == JNI_OK);
5200         }
5201         int64_t idx_conv = idx;
5202         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5203         CHECK(obj != NULL);
5204         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx_conv);
5205         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5206                 (*env)->ExceptionDescribe(env);
5207                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
5208         }
5209         LDKPublicKey ret_ref;
5210         CHECK((*env)->GetArrayLength(env, ret) == 33);
5211         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
5212         if (get_jenv_res == JNI_EDETACHED) {
5213                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5214         }
5215         return ret_ref;
5216 }
5217 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
5218         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5219         JNIEnv *env;
5220         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5221         if (get_jenv_res == JNI_EDETACHED) {
5222                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5223         } else {
5224                 DO_ASSERT(get_jenv_res == JNI_OK);
5225         }
5226         int64_t idx_conv = idx;
5227         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5228         CHECK(obj != NULL);
5229         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx_conv);
5230         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5231                 (*env)->ExceptionDescribe(env);
5232                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
5233         }
5234         LDKThirtyTwoBytes ret_ref;
5235         CHECK((*env)->GetArrayLength(env, ret) == 32);
5236         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5237         if (get_jenv_res == JNI_EDETACHED) {
5238                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5239         }
5240         return ret_ref;
5241 }
5242 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
5243         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5244         JNIEnv *env;
5245         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5246         if (get_jenv_res == JNI_EDETACHED) {
5247                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5248         } else {
5249                 DO_ASSERT(get_jenv_res == JNI_OK);
5250         }
5251         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
5252         int64_t holder_tx_ref = 0;
5253         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
5254         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
5255         holder_tx_ref = tag_ptr(holder_tx_var.inner, holder_tx_var.is_owned);
5256         LDKCVec_PaymentPreimageZ preimages_var = preimages;
5257         jobjectArray preimages_arr = NULL;
5258         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
5259         ;
5260         for (size_t i = 0; i < preimages_var.datalen; i++) {
5261                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
5262                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
5263                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
5264         }
5265         
5266         FREE(preimages_var.data);
5267         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5268         CHECK(obj != NULL);
5269         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref, preimages_arr);
5270         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5271                 (*env)->ExceptionDescribe(env);
5272                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
5273         }
5274         void* ret_ptr = untag_ptr(ret);
5275         CHECK_ACCESS(ret_ptr);
5276         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
5277         FREE(untag_ptr(ret));
5278         if (get_jenv_res == JNI_EDETACHED) {
5279                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5280         }
5281         return ret_conv;
5282 }
5283 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
5284         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5285         JNIEnv *env;
5286         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5287         if (get_jenv_res == JNI_EDETACHED) {
5288                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5289         } else {
5290                 DO_ASSERT(get_jenv_res == JNI_OK);
5291         }
5292         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5293         CHECK(obj != NULL);
5294         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
5295         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5296                 (*env)->ExceptionDescribe(env);
5297                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
5298         }
5299         LDKThirtyTwoBytes ret_ref;
5300         CHECK((*env)->GetArrayLength(env, ret) == 32);
5301         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5302         if (get_jenv_res == JNI_EDETACHED) {
5303                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5304         }
5305         return ret_ref;
5306 }
5307 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
5308         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5309         JNIEnv *env;
5310         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5311         if (get_jenv_res == JNI_EDETACHED) {
5312                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5313         } else {
5314                 DO_ASSERT(get_jenv_res == JNI_OK);
5315         }
5316         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
5317         int64_t commitment_tx_ref = 0;
5318         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
5319         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
5320         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
5321         LDKCVec_PaymentPreimageZ preimages_var = preimages;
5322         jobjectArray preimages_arr = NULL;
5323         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
5324         ;
5325         for (size_t i = 0; i < preimages_var.datalen; i++) {
5326                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
5327                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
5328                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
5329         }
5330         
5331         FREE(preimages_var.data);
5332         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5333         CHECK(obj != NULL);
5334         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref, preimages_arr);
5335         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5336                 (*env)->ExceptionDescribe(env);
5337                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
5338         }
5339         void* ret_ptr = untag_ptr(ret);
5340         CHECK_ACCESS(ret_ptr);
5341         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
5342         FREE(untag_ptr(ret));
5343         if (get_jenv_res == JNI_EDETACHED) {
5344                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5345         }
5346         return ret_conv;
5347 }
5348 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
5349         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5350         JNIEnv *env;
5351         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5352         if (get_jenv_res == JNI_EDETACHED) {
5353                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5354         } else {
5355                 DO_ASSERT(get_jenv_res == JNI_OK);
5356         }
5357         int64_t idx_conv = idx;
5358         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
5359         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
5360         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5361         CHECK(obj != NULL);
5362         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx_conv, secret_arr);
5363         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5364                 (*env)->ExceptionDescribe(env);
5365                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
5366         }
5367         void* ret_ptr = untag_ptr(ret);
5368         CHECK_ACCESS(ret_ptr);
5369         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
5370         FREE(untag_ptr(ret));
5371         if (get_jenv_res == JNI_EDETACHED) {
5372                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5373         }
5374         return ret_conv;
5375 }
5376 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
5377         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
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         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
5386         int64_t commitment_tx_ref = 0;
5387         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
5388         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
5389         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
5390         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5391         CHECK(obj != NULL);
5392         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
5393         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5394                 (*env)->ExceptionDescribe(env);
5395                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
5396         }
5397         void* ret_ptr = untag_ptr(ret);
5398         CHECK_ACCESS(ret_ptr);
5399         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
5400         FREE(untag_ptr(ret));
5401         if (get_jenv_res == JNI_EDETACHED) {
5402                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5403         }
5404         return ret_conv;
5405 }
5406 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]) {
5407         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5408         JNIEnv *env;
5409         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5410         if (get_jenv_res == JNI_EDETACHED) {
5411                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5412         } else {
5413                 DO_ASSERT(get_jenv_res == JNI_OK);
5414         }
5415         LDKTransaction justice_tx_var = justice_tx;
5416         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
5417         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
5418         Transaction_free(justice_tx_var);
5419         int64_t input_conv = input;
5420         int64_t amount_conv = amount;
5421         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
5422         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
5423         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5424         CHECK(obj != NULL);
5425         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input_conv, amount_conv, per_commitment_key_arr);
5426         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5427                 (*env)->ExceptionDescribe(env);
5428                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
5429         }
5430         void* ret_ptr = untag_ptr(ret);
5431         CHECK_ACCESS(ret_ptr);
5432         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5433         FREE(untag_ptr(ret));
5434         if (get_jenv_res == JNI_EDETACHED) {
5435                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5436         }
5437         return ret_conv;
5438 }
5439 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) {
5440         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5441         JNIEnv *env;
5442         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5443         if (get_jenv_res == JNI_EDETACHED) {
5444                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5445         } else {
5446                 DO_ASSERT(get_jenv_res == JNI_OK);
5447         }
5448         LDKTransaction justice_tx_var = justice_tx;
5449         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
5450         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
5451         Transaction_free(justice_tx_var);
5452         int64_t input_conv = input;
5453         int64_t amount_conv = amount;
5454         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
5455         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
5456         LDKHTLCOutputInCommitment htlc_var = *htlc;
5457         int64_t htlc_ref = 0;
5458         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
5459         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
5460         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
5461         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5462         CHECK(obj != NULL);
5463         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input_conv, amount_conv, per_commitment_key_arr, htlc_ref);
5464         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5465                 (*env)->ExceptionDescribe(env);
5466                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
5467         }
5468         void* ret_ptr = untag_ptr(ret);
5469         CHECK_ACCESS(ret_ptr);
5470         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5471         FREE(untag_ptr(ret));
5472         if (get_jenv_res == JNI_EDETACHED) {
5473                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5474         }
5475         return ret_conv;
5476 }
5477 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) {
5478         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5479         JNIEnv *env;
5480         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5481         if (get_jenv_res == JNI_EDETACHED) {
5482                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5483         } else {
5484                 DO_ASSERT(get_jenv_res == JNI_OK);
5485         }
5486         LDKTransaction htlc_tx_var = htlc_tx;
5487         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
5488         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
5489         Transaction_free(htlc_tx_var);
5490         int64_t input_conv = input;
5491         int64_t amount_conv = amount;
5492         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
5493         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
5494         LDKHTLCOutputInCommitment htlc_var = *htlc;
5495         int64_t htlc_ref = 0;
5496         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
5497         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
5498         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
5499         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5500         CHECK(obj != NULL);
5501         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input_conv, amount_conv, per_commitment_point_arr, htlc_ref);
5502         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5503                 (*env)->ExceptionDescribe(env);
5504                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
5505         }
5506         void* ret_ptr = untag_ptr(ret);
5507         CHECK_ACCESS(ret_ptr);
5508         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5509         FREE(untag_ptr(ret));
5510         if (get_jenv_res == JNI_EDETACHED) {
5511                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5512         }
5513         return ret_conv;
5514 }
5515 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
5516         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5517         JNIEnv *env;
5518         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5519         if (get_jenv_res == JNI_EDETACHED) {
5520                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5521         } else {
5522                 DO_ASSERT(get_jenv_res == JNI_OK);
5523         }
5524         LDKClosingTransaction closing_tx_var = *closing_tx;
5525         int64_t closing_tx_ref = 0;
5526         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
5527         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
5528         closing_tx_ref = tag_ptr(closing_tx_var.inner, closing_tx_var.is_owned);
5529         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5530         CHECK(obj != NULL);
5531         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
5532         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5533                 (*env)->ExceptionDescribe(env);
5534                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
5535         }
5536         void* ret_ptr = untag_ptr(ret);
5537         CHECK_ACCESS(ret_ptr);
5538         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5539         FREE(untag_ptr(ret));
5540         if (get_jenv_res == JNI_EDETACHED) {
5541                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5542         }
5543         return ret_conv;
5544 }
5545 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
5546         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5547         JNIEnv *env;
5548         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5549         if (get_jenv_res == JNI_EDETACHED) {
5550                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5551         } else {
5552                 DO_ASSERT(get_jenv_res == JNI_OK);
5553         }
5554         LDKUnsignedChannelAnnouncement msg_var = *msg;
5555         int64_t msg_ref = 0;
5556         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
5557         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
5558         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
5559         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5560         CHECK(obj != NULL);
5561         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
5562         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5563                 (*env)->ExceptionDescribe(env);
5564                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
5565         }
5566         void* ret_ptr = untag_ptr(ret);
5567         CHECK_ACCESS(ret_ptr);
5568         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
5569         FREE(untag_ptr(ret));
5570         if (get_jenv_res == JNI_EDETACHED) {
5571                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5572         }
5573         return ret_conv;
5574 }
5575 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
5576         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5577         JNIEnv *env;
5578         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5579         if (get_jenv_res == JNI_EDETACHED) {
5580                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5581         } else {
5582                 DO_ASSERT(get_jenv_res == JNI_OK);
5583         }
5584         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
5585         int64_t channel_parameters_ref = 0;
5586         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
5587         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
5588         channel_parameters_ref = tag_ptr(channel_parameters_var.inner, channel_parameters_var.is_owned);
5589         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5590         CHECK(obj != NULL);
5591         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
5592         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5593                 (*env)->ExceptionDescribe(env);
5594                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
5595         }
5596         if (get_jenv_res == JNI_EDETACHED) {
5597                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5598         }
5599 }
5600 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5601         jclass c = (*env)->GetObjectClass(env, o);
5602         CHECK(c != NULL);
5603         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
5604         atomic_init(&calls->refcnt, 1);
5605         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5606         calls->o = (*env)->NewWeakGlobalRef(env, o);
5607         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
5608         CHECK(calls->get_per_commitment_point_meth != NULL);
5609         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
5610         CHECK(calls->release_commitment_secret_meth != NULL);
5611         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J[[B)J");
5612         CHECK(calls->validate_holder_commitment_meth != NULL);
5613         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
5614         CHECK(calls->channel_keys_id_meth != NULL);
5615         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J[[B)J");
5616         CHECK(calls->sign_counterparty_commitment_meth != NULL);
5617         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
5618         CHECK(calls->validate_counterparty_revocation_meth != NULL);
5619         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
5620         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
5621         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
5622         CHECK(calls->sign_justice_revoked_output_meth != NULL);
5623         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
5624         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
5625         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
5626         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
5627         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
5628         CHECK(calls->sign_closing_transaction_meth != NULL);
5629         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
5630         CHECK(calls->sign_channel_announcement_meth != NULL);
5631         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
5632         CHECK(calls->ready_channel_meth != NULL);
5633
5634         LDKChannelPublicKeys pubkeys_conv;
5635         pubkeys_conv.inner = untag_ptr(pubkeys);
5636         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
5637         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
5638
5639         LDKBaseSign ret = {
5640                 .this_arg = (void*) calls,
5641                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
5642                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
5643                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
5644                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
5645                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
5646                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
5647                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
5648                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
5649                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
5650                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
5651                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
5652                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
5653                 .ready_channel = ready_channel_LDKBaseSign_jcall,
5654                 .free = LDKBaseSign_JCalls_free,
5655                 .pubkeys = pubkeys_conv,
5656                 .set_pubkeys = NULL,
5657         };
5658         return ret;
5659 }
5660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5661         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
5662         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
5663         return tag_ptr(res_ptr, true);
5664 }
5665 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) {
5666         void* this_arg_ptr = untag_ptr(this_arg);
5667         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5668         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5669         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5670         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
5671         return ret_arr;
5672 }
5673
5674 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
5675         void* this_arg_ptr = untag_ptr(this_arg);
5676         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5677         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5678         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5679         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
5680         return ret_arr;
5681 }
5682
5683 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) {
5684         void* this_arg_ptr = untag_ptr(this_arg);
5685         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5686         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5687         LDKHolderCommitmentTransaction holder_tx_conv;
5688         holder_tx_conv.inner = untag_ptr(holder_tx);
5689         holder_tx_conv.is_owned = ptr_is_owned(holder_tx);
5690         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
5691         holder_tx_conv.is_owned = false;
5692         LDKCVec_PaymentPreimageZ preimages_constr;
5693         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5694         if (preimages_constr.datalen > 0)
5695                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5696         else
5697                 preimages_constr.data = NULL;
5698         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5699                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5700                 LDKThirtyTwoBytes preimages_conv_8_ref;
5701                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5702                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5703                 preimages_constr.data[i] = preimages_conv_8_ref;
5704         }
5705         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5706         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
5707         return tag_ptr(ret_conv, true);
5708 }
5709
5710 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
5711         void* this_arg_ptr = untag_ptr(this_arg);
5712         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5713         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5714         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5715         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
5716         return ret_arr;
5717 }
5718
5719 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) {
5720         void* this_arg_ptr = untag_ptr(this_arg);
5721         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5722         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5723         LDKCommitmentTransaction commitment_tx_conv;
5724         commitment_tx_conv.inner = untag_ptr(commitment_tx);
5725         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
5726         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
5727         commitment_tx_conv.is_owned = false;
5728         LDKCVec_PaymentPreimageZ preimages_constr;
5729         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5730         if (preimages_constr.datalen > 0)
5731                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5732         else
5733                 preimages_constr.data = NULL;
5734         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5735                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5736                 LDKThirtyTwoBytes preimages_conv_8_ref;
5737                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5738                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5739                 preimages_constr.data[i] = preimages_conv_8_ref;
5740         }
5741         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5742         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
5743         return tag_ptr(ret_conv, true);
5744 }
5745
5746 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) {
5747         void* this_arg_ptr = untag_ptr(this_arg);
5748         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5749         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5750         unsigned char secret_arr[32];
5751         CHECK((*env)->GetArrayLength(env, secret) == 32);
5752         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
5753         unsigned char (*secret_ref)[32] = &secret_arr;
5754         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5755         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
5756         return tag_ptr(ret_conv, true);
5757 }
5758
5759 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) {
5760         void* this_arg_ptr = untag_ptr(this_arg);
5761         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5762         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5763         LDKHolderCommitmentTransaction commitment_tx_conv;
5764         commitment_tx_conv.inner = untag_ptr(commitment_tx);
5765         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
5766         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
5767         commitment_tx_conv.is_owned = false;
5768         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5769         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
5770         return tag_ptr(ret_conv, true);
5771 }
5772
5773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1justice_1revoked_1output(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key) {
5774         void* this_arg_ptr = untag_ptr(this_arg);
5775         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5776         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5777         LDKTransaction justice_tx_ref;
5778         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
5779         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
5780         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
5781         justice_tx_ref.data_is_owned = true;
5782         unsigned char per_commitment_key_arr[32];
5783         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
5784         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
5785         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
5786         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5787         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
5788         return tag_ptr(ret_conv, true);
5789 }
5790
5791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1justice_1revoked_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key, int64_t htlc) {
5792         void* this_arg_ptr = untag_ptr(this_arg);
5793         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5794         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5795         LDKTransaction justice_tx_ref;
5796         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
5797         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
5798         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
5799         justice_tx_ref.data_is_owned = true;
5800         unsigned char per_commitment_key_arr[32];
5801         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
5802         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
5803         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
5804         LDKHTLCOutputInCommitment htlc_conv;
5805         htlc_conv.inner = untag_ptr(htlc);
5806         htlc_conv.is_owned = ptr_is_owned(htlc);
5807         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
5808         htlc_conv.is_owned = false;
5809         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5810         *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);
5811         return tag_ptr(ret_conv, true);
5812 }
5813
5814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterparty_1htlc_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray htlc_tx, int64_t input, int64_t amount, int8_tArray per_commitment_point, int64_t htlc) {
5815         void* this_arg_ptr = untag_ptr(this_arg);
5816         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5817         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5818         LDKTransaction htlc_tx_ref;
5819         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
5820         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
5821         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
5822         htlc_tx_ref.data_is_owned = true;
5823         LDKPublicKey per_commitment_point_ref;
5824         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
5825         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
5826         LDKHTLCOutputInCommitment htlc_conv;
5827         htlc_conv.inner = untag_ptr(htlc);
5828         htlc_conv.is_owned = ptr_is_owned(htlc);
5829         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
5830         htlc_conv.is_owned = false;
5831         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5832         *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);
5833         return tag_ptr(ret_conv, true);
5834 }
5835
5836 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) {
5837         void* this_arg_ptr = untag_ptr(this_arg);
5838         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5839         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5840         LDKClosingTransaction closing_tx_conv;
5841         closing_tx_conv.inner = untag_ptr(closing_tx);
5842         closing_tx_conv.is_owned = ptr_is_owned(closing_tx);
5843         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
5844         closing_tx_conv.is_owned = false;
5845         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5846         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
5847         return tag_ptr(ret_conv, true);
5848 }
5849
5850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
5851         void* this_arg_ptr = untag_ptr(this_arg);
5852         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5853         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5854         LDKUnsignedChannelAnnouncement msg_conv;
5855         msg_conv.inner = untag_ptr(msg);
5856         msg_conv.is_owned = ptr_is_owned(msg);
5857         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
5858         msg_conv.is_owned = false;
5859         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
5860         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
5861         return tag_ptr(ret_conv, true);
5862 }
5863
5864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
5865         void* this_arg_ptr = untag_ptr(this_arg);
5866         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5867         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5868         LDKChannelTransactionParameters channel_parameters_conv;
5869         channel_parameters_conv.inner = untag_ptr(channel_parameters);
5870         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
5871         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
5872         channel_parameters_conv.is_owned = false;
5873         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
5874 }
5875
5876 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
5877         if (this_arg->set_pubkeys != NULL)
5878                 this_arg->set_pubkeys(this_arg);
5879         return this_arg->pubkeys;
5880 }
5881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
5882         void* this_arg_ptr = untag_ptr(this_arg);
5883         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5884         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5885         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
5886         int64_t ret_ref = 0;
5887         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5888         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5889         return ret_ref;
5890 }
5891
5892 typedef struct LDKSign_JCalls {
5893         atomic_size_t refcnt;
5894         JavaVM *vm;
5895         jweak o;
5896         LDKBaseSign_JCalls* BaseSign;
5897         jmethodID write_meth;
5898 } LDKSign_JCalls;
5899 static void LDKSign_JCalls_free(void* this_arg) {
5900         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
5901         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5902                 JNIEnv *env;
5903                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5904                 if (get_jenv_res == JNI_EDETACHED) {
5905                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5906                 } else {
5907                         DO_ASSERT(get_jenv_res == JNI_OK);
5908                 }
5909                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5910                 if (get_jenv_res == JNI_EDETACHED) {
5911                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5912                 }
5913                 FREE(j_calls);
5914         }
5915 }
5916 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
5917         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
5918         JNIEnv *env;
5919         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5920         if (get_jenv_res == JNI_EDETACHED) {
5921                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5922         } else {
5923                 DO_ASSERT(get_jenv_res == JNI_OK);
5924         }
5925         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5926         CHECK(obj != NULL);
5927         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
5928         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5929                 (*env)->ExceptionDescribe(env);
5930                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
5931         }
5932         LDKCVec_u8Z ret_ref;
5933         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
5934         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5935         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
5936         if (get_jenv_res == JNI_EDETACHED) {
5937                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5938         }
5939         return ret_ref;
5940 }
5941 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
5942         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
5943         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5944         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
5945 }
5946 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
5947         jclass c = (*env)->GetObjectClass(env, o);
5948         CHECK(c != NULL);
5949         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
5950         atomic_init(&calls->refcnt, 1);
5951         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5952         calls->o = (*env)->NewWeakGlobalRef(env, o);
5953         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
5954         CHECK(calls->write_meth != NULL);
5955
5956         LDKChannelPublicKeys pubkeys_conv;
5957         pubkeys_conv.inner = untag_ptr(pubkeys);
5958         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
5959         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
5960
5961         LDKSign ret = {
5962                 .this_arg = (void*) calls,
5963                 .write = write_LDKSign_jcall,
5964                 .cloned = LDKSign_JCalls_cloned,
5965                 .free = LDKSign_JCalls_free,
5966                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
5967         };
5968         calls->BaseSign = ret.BaseSign.this_arg;
5969         return ret;
5970 }
5971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
5972         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
5973         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
5974         return tag_ptr(res_ptr, true);
5975 }
5976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
5977         LDKSign *inp = (LDKSign *)untag_ptr(arg);
5978         return tag_ptr(&inp->BaseSign, false);
5979 }
5980 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
5981         void* this_arg_ptr = untag_ptr(this_arg);
5982         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5983         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
5984         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5985         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5986         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5987         CVec_u8Z_free(ret_var);
5988         return ret_arr;
5989 }
5990
5991 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
5992 CHECK(owner->result_ok);
5993         return Sign_clone(&*owner->contents.result);
5994 }
5995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5996         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(owner);
5997         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
5998         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
5999         return tag_ptr(ret_ret, true);
6000 }
6001
6002 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
6003         LDKDecodeError ret = *owner->contents.err;
6004         ret.is_owned = false;
6005         return ret;
6006 }
6007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6008         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(owner);
6009         LDKDecodeError ret_var = CResult_SignDecodeErrorZ_get_err(owner_conv);
6010         int64_t ret_ref = 0;
6011         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6012         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6013         return ret_ref;
6014 }
6015
6016 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
6017 CHECK(owner->result_ok);
6018         return *owner->contents.result;
6019 }
6020 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6021         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
6022         int8_tArray ret_arr = (*env)->NewByteArray(env, 68);
6023         (*env)->SetByteArrayRegion(env, ret_arr, 0, 68, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form);
6024         return ret_arr;
6025 }
6026
6027 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
6028 CHECK(!owner->result_ok);
6029         return *owner->contents.err;
6030 }
6031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6032         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
6033         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
6034 }
6035
6036 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
6037         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
6038         for (size_t i = 0; i < ret.datalen; i++) {
6039                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
6040         }
6041         return ret;
6042 }
6043 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
6044 CHECK(owner->result_ok);
6045         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
6046 }
6047 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6048         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
6049         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
6050         jobjectArray ret_arr = NULL;
6051         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
6052         ;
6053         for (size_t i = 0; i < ret_var.datalen; i++) {
6054                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
6055                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
6056                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
6057                 CVec_u8Z_free(ret_conv_8_var);
6058                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
6059         }
6060         
6061         FREE(ret_var.data);
6062         return ret_arr;
6063 }
6064
6065 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
6066 CHECK(!owner->result_ok);
6067         return *owner->contents.err;
6068 }
6069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6070         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
6071         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
6072 }
6073
6074 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
6075         LDKInMemorySigner ret = *owner->contents.result;
6076         ret.is_owned = false;
6077         return ret;
6078 }
6079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6080         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
6081         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
6082         int64_t ret_ref = 0;
6083         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6084         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6085         return ret_ref;
6086 }
6087
6088 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
6089         LDKDecodeError ret = *owner->contents.err;
6090         ret.is_owned = false;
6091         return ret;
6092 }
6093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6094         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
6095         LDKDecodeError ret_var = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
6096         int64_t ret_ref = 0;
6097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6098         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6099         return ret_ref;
6100 }
6101
6102 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
6103         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
6104         for (size_t i = 0; i < ret.datalen; i++) {
6105                 ret.data[i] = TxOut_clone(&orig->data[i]);
6106         }
6107         return ret;
6108 }
6109 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
6110 CHECK(owner->result_ok);
6111         return *owner->contents.result;
6112 }
6113 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6114         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
6115         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
6116         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6117         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6118         return ret_arr;
6119 }
6120
6121 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
6122 CHECK(!owner->result_ok);
6123         return *owner->contents.err;
6124 }
6125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6126         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
6127         CResult_TransactionNoneZ_get_err(owner_conv);
6128 }
6129
6130 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6131         return ThirtyTwoBytes_clone(&owner->a);
6132 }
6133 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6134         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(owner);
6135         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6136         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data);
6137         return ret_arr;
6138 }
6139
6140 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6141         LDKChannelMonitor ret = owner->b;
6142         ret.is_owned = false;
6143         return ret;
6144 }
6145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6146         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(owner);
6147         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
6148         int64_t ret_ref = 0;
6149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6150         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6151         return ret_ref;
6152 }
6153
6154 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
6155         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
6156         for (size_t i = 0; i < ret.datalen; i++) {
6157                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
6158         }
6159         return ret;
6160 }
6161 static inline struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
6162 CHECK(owner->result_ok);
6163         return CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(&*owner->contents.result);
6164 }
6165 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6166         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(owner);
6167         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(owner_conv);
6168         int64_tArray ret_arr = NULL;
6169         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6170         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6171         for (size_t j = 0; j < ret_var.datalen; j++) {
6172                 LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
6173                 *ret_conv_35_conv = ret_var.data[j];
6174                 ret_arr_ptr[j] = tag_ptr(ret_conv_35_conv, true);
6175         }
6176         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6177         FREE(ret_var.data);
6178         return ret_arr;
6179 }
6180
6181 static inline enum LDKIOError CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
6182 CHECK(!owner->result_ok);
6183         return *owner->contents.err;
6184 }
6185 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6186         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(owner);
6187         jclass ret_conv = LDKIOError_to_java(env, CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(owner_conv));
6188         return ret_conv;
6189 }
6190
6191 static jclass LDKCOption_u16Z_Some_class = NULL;
6192 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
6193 static jclass LDKCOption_u16Z_None_class = NULL;
6194 static jmethodID LDKCOption_u16Z_None_meth = NULL;
6195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
6196         LDKCOption_u16Z_Some_class =
6197                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
6198         CHECK(LDKCOption_u16Z_Some_class != NULL);
6199         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
6200         CHECK(LDKCOption_u16Z_Some_meth != NULL);
6201         LDKCOption_u16Z_None_class =
6202                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
6203         CHECK(LDKCOption_u16Z_None_class != NULL);
6204         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
6205         CHECK(LDKCOption_u16Z_None_meth != NULL);
6206 }
6207 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6208         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)untag_ptr(ptr);
6209         switch(obj->tag) {
6210                 case LDKCOption_u16Z_Some: {
6211                         int16_t some_conv = obj->some;
6212                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, some_conv);
6213                 }
6214                 case LDKCOption_u16Z_None: {
6215                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
6216                 }
6217                 default: abort();
6218         }
6219 }
6220 static jclass LDKAPIError_APIMisuseError_class = NULL;
6221 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
6222 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
6223 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
6224 static jclass LDKAPIError_RouteError_class = NULL;
6225 static jmethodID LDKAPIError_RouteError_meth = NULL;
6226 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
6227 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
6228 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
6229 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
6230 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
6231 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
6232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
6233         LDKAPIError_APIMisuseError_class =
6234                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
6235         CHECK(LDKAPIError_APIMisuseError_class != NULL);
6236         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
6237         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
6238         LDKAPIError_FeeRateTooHigh_class =
6239                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
6240         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
6241         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
6242         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
6243         LDKAPIError_RouteError_class =
6244                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$RouteError"));
6245         CHECK(LDKAPIError_RouteError_class != NULL);
6246         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
6247         CHECK(LDKAPIError_RouteError_meth != NULL);
6248         LDKAPIError_ChannelUnavailable_class =
6249                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
6250         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
6251         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
6252         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
6253         LDKAPIError_MonitorUpdateFailed_class =
6254                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed"));
6255         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
6256         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
6257         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
6258         LDKAPIError_IncompatibleShutdownScript_class =
6259                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
6260         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
6261         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
6262         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
6263 }
6264 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6265         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
6266         switch(obj->tag) {
6267                 case LDKAPIError_APIMisuseError: {
6268                         LDKStr err_str = obj->api_misuse_error.err;
6269                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
6270                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
6271                 }
6272                 case LDKAPIError_FeeRateTooHigh: {
6273                         LDKStr err_str = obj->fee_rate_too_high.err;
6274                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
6275                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
6276                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, feerate_conv);
6277                 }
6278                 case LDKAPIError_RouteError: {
6279                         LDKStr err_str = obj->route_error.err;
6280                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
6281                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
6282                 }
6283                 case LDKAPIError_ChannelUnavailable: {
6284                         LDKStr err_str = obj->channel_unavailable.err;
6285                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
6286                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
6287                 }
6288                 case LDKAPIError_MonitorUpdateFailed: {
6289                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
6290                 }
6291                 case LDKAPIError_IncompatibleShutdownScript: {
6292                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
6293                         int64_t script_ref = 0;
6294                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
6295                         script_ref = tag_ptr(script_var.inner, false);
6296                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
6297                 }
6298                 default: abort();
6299         }
6300 }
6301 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
6302 CHECK(owner->result_ok);
6303         return *owner->contents.result;
6304 }
6305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6306         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
6307         CResult_NoneAPIErrorZ_get_ok(owner_conv);
6308 }
6309
6310 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
6311 CHECK(!owner->result_ok);
6312         return APIError_clone(&*owner->contents.err);
6313 }
6314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6315         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
6316         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6317         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
6318         int64_t ret_ref = tag_ptr(ret_copy, true);
6319         return ret_ref;
6320 }
6321
6322 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
6323         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
6324         for (size_t i = 0; i < ret.datalen; i++) {
6325                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
6326         }
6327         return ret;
6328 }
6329 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
6330         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
6331         for (size_t i = 0; i < ret.datalen; i++) {
6332                 ret.data[i] = APIError_clone(&orig->data[i]);
6333         }
6334         return ret;
6335 }
6336 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
6337 CHECK(owner->result_ok);
6338         return ThirtyTwoBytes_clone(&*owner->contents.result);
6339 }
6340 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6341         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(owner);
6342         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6343         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult__u832APIErrorZ_get_ok(owner_conv).data);
6344         return ret_arr;
6345 }
6346
6347 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
6348 CHECK(!owner->result_ok);
6349         return APIError_clone(&*owner->contents.err);
6350 }
6351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6352         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(owner);
6353         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6354         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
6355         int64_t ret_ref = tag_ptr(ret_copy, true);
6356         return ret_ref;
6357 }
6358
6359 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
6360 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
6361 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
6362 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
6363 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
6364 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
6365 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
6366 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
6367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
6368         LDKPaymentSendFailure_ParameterError_class =
6369                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
6370         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
6371         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
6372         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
6373         LDKPaymentSendFailure_PathParameterError_class =
6374                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
6375         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
6376         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
6377         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
6378         LDKPaymentSendFailure_AllFailedRetrySafe_class =
6379                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe"));
6380         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
6381         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
6382         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
6383         LDKPaymentSendFailure_PartialFailure_class =
6384                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
6385         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
6386         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
6387         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
6388 }
6389 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6390         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
6391         switch(obj->tag) {
6392                 case LDKPaymentSendFailure_ParameterError: {
6393                         int64_t parameter_error_ref = tag_ptr(&obj->parameter_error, false);
6394                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
6395                 }
6396                 case LDKPaymentSendFailure_PathParameterError: {
6397                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
6398                         int64_tArray path_parameter_error_arr = NULL;
6399                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
6400                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
6401                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
6402                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6403                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
6404                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
6405                                 path_parameter_error_arr_ptr[w] = tag_ptr(path_parameter_error_conv_22_conv, true);
6406                         }
6407                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
6408                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
6409                 }
6410                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
6411                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
6412                         int64_tArray all_failed_retry_safe_arr = NULL;
6413                         all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
6414                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
6415                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
6416                                 int64_t all_failed_retry_safe_conv_10_ref = tag_ptr(&all_failed_retry_safe_var.data[k], false);
6417                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
6418                         }
6419                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
6420                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
6421                 }
6422                 case LDKPaymentSendFailure_PartialFailure: {
6423                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
6424                         int64_tArray results_arr = NULL;
6425                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
6426                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
6427                         for (size_t w = 0; w < results_var.datalen; w++) {
6428                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6429                                 *results_conv_22_conv = results_var.data[w];
6430                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
6431                                 results_arr_ptr[w] = tag_ptr(results_conv_22_conv, true);
6432                         }
6433                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
6434                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
6435                         int64_t failed_paths_retry_ref = 0;
6436                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
6437                         failed_paths_retry_ref = tag_ptr(failed_paths_retry_var.inner, false);
6438                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
6439                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
6440                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
6441                 }
6442                 default: abort();
6443         }
6444 }
6445 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentSendFailureZ_get_ok(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
6446 CHECK(owner->result_ok);
6447         return ThirtyTwoBytes_clone(&*owner->contents.result);
6448 }
6449 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6450         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(owner);
6451         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6452         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentSendFailureZ_get_ok(owner_conv).data);
6453         return ret_arr;
6454 }
6455
6456 static inline struct LDKPaymentSendFailure CResult_PaymentIdPaymentSendFailureZ_get_err(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR owner){
6457 CHECK(!owner->result_ok);
6458         return PaymentSendFailure_clone(&*owner->contents.err);
6459 }
6460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6461         LDKCResult_PaymentIdPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(owner);
6462         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6463         *ret_copy = CResult_PaymentIdPaymentSendFailureZ_get_err(owner_conv);
6464         int64_t ret_ref = tag_ptr(ret_copy, true);
6465         return ret_ref;
6466 }
6467
6468 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6469 CHECK(owner->result_ok);
6470         return *owner->contents.result;
6471 }
6472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6473         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
6474         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
6475 }
6476
6477 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6478 CHECK(!owner->result_ok);
6479         return PaymentSendFailure_clone(&*owner->contents.err);
6480 }
6481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6482         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
6483         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6484         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
6485         int64_t ret_ref = tag_ptr(ret_copy, true);
6486         return ret_ref;
6487 }
6488
6489 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
6490         return ThirtyTwoBytes_clone(&owner->a);
6491 }
6492 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6493         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(owner);
6494         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6495         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data);
6496         return ret_arr;
6497 }
6498
6499 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
6500         return ThirtyTwoBytes_clone(&owner->b);
6501 }
6502 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6503         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(owner);
6504         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6505         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data);
6506         return ret_arr;
6507 }
6508
6509 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
6510 CHECK(owner->result_ok);
6511         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
6512 }
6513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6514         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(owner);
6515         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
6516         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
6517         return tag_ptr(ret_conv, true);
6518 }
6519
6520 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
6521 CHECK(!owner->result_ok);
6522         return PaymentSendFailure_clone(&*owner->contents.err);
6523 }
6524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6525         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(owner);
6526         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6527         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
6528         int64_t ret_ref = tag_ptr(ret_copy, true);
6529         return ret_ref;
6530 }
6531
6532 static inline LDKCVec_ThirtyTwoBytesZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_ThirtyTwoBytesZ *orig) {
6533         LDKCVec_ThirtyTwoBytesZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ThirtyTwoBytesZ clone bytes"), .datalen = orig->datalen };
6534         for (size_t i = 0; i < ret.datalen; i++) {
6535                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
6536         }
6537         return ret;
6538 }
6539 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6540         return ThirtyTwoBytes_clone(&owner->a);
6541 }
6542 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6543         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(owner);
6544         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6545         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data);
6546         return ret_arr;
6547 }
6548
6549 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6550         return ThirtyTwoBytes_clone(&owner->b);
6551 }
6552 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6553         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(owner);
6554         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6555         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data);
6556         return ret_arr;
6557 }
6558
6559 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6560 CHECK(owner->result_ok);
6561         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6562 }
6563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6564         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(owner);
6565         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6566         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
6567         return tag_ptr(ret_conv, true);
6568 }
6569
6570 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6571 CHECK(!owner->result_ok);
6572         return *owner->contents.err;
6573 }
6574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6575         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(owner);
6576         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
6577 }
6578
6579 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6580 CHECK(owner->result_ok);
6581         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6582 }
6583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6584         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(owner);
6585         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6586         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
6587         return tag_ptr(ret_conv, true);
6588 }
6589
6590 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6591 CHECK(!owner->result_ok);
6592         return APIError_clone(&*owner->contents.err);
6593 }
6594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6595         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(owner);
6596         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6597         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
6598         int64_t ret_ref = tag_ptr(ret_copy, true);
6599         return ret_ref;
6600 }
6601
6602 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6603 CHECK(owner->result_ok);
6604         return ThirtyTwoBytes_clone(&*owner->contents.result);
6605 }
6606 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6607         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(owner);
6608         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6609         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data);
6610         return ret_arr;
6611 }
6612
6613 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6614 CHECK(!owner->result_ok);
6615         return *owner->contents.err;
6616 }
6617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6618         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(owner);
6619         CResult_PaymentSecretNoneZ_get_err(owner_conv);
6620 }
6621
6622 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6623 CHECK(owner->result_ok);
6624         return ThirtyTwoBytes_clone(&*owner->contents.result);
6625 }
6626 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6627         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(owner);
6628         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6629         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data);
6630         return ret_arr;
6631 }
6632
6633 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6634 CHECK(!owner->result_ok);
6635         return APIError_clone(&*owner->contents.err);
6636 }
6637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6638         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(owner);
6639         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6640         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
6641         int64_t ret_ref = tag_ptr(ret_copy, true);
6642         return ret_ref;
6643 }
6644
6645 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6646 CHECK(owner->result_ok);
6647         return ThirtyTwoBytes_clone(&*owner->contents.result);
6648 }
6649 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6650         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(owner);
6651         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6652         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data);
6653         return ret_arr;
6654 }
6655
6656 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6657 CHECK(!owner->result_ok);
6658         return APIError_clone(&*owner->contents.err);
6659 }
6660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6661         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(owner);
6662         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6663         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
6664         int64_t ret_ref = tag_ptr(ret_copy, true);
6665         return ret_ref;
6666 }
6667
6668 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
6669         LDKCounterpartyForwardingInfo ret = *owner->contents.result;
6670         ret.is_owned = false;
6671         return ret;
6672 }
6673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6674         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
6675         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
6676         int64_t ret_ref = 0;
6677         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6678         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6679         return ret_ref;
6680 }
6681
6682 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
6683         LDKDecodeError ret = *owner->contents.err;
6684         ret.is_owned = false;
6685         return ret;
6686 }
6687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6688         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
6689         LDKDecodeError ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
6690         int64_t ret_ref = 0;
6691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6692         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6693         return ret_ref;
6694 }
6695
6696 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
6697         LDKChannelCounterparty ret = *owner->contents.result;
6698         ret.is_owned = false;
6699         return ret;
6700 }
6701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6702         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
6703         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
6704         int64_t ret_ref = 0;
6705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6706         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6707         return ret_ref;
6708 }
6709
6710 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
6711         LDKDecodeError ret = *owner->contents.err;
6712         ret.is_owned = false;
6713         return ret;
6714 }
6715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6716         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
6717         LDKDecodeError ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
6718         int64_t ret_ref = 0;
6719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6720         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6721         return ret_ref;
6722 }
6723
6724 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
6725         LDKChannelDetails ret = *owner->contents.result;
6726         ret.is_owned = false;
6727         return ret;
6728 }
6729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6730         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
6731         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
6732         int64_t ret_ref = 0;
6733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6734         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6735         return ret_ref;
6736 }
6737
6738 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
6739         LDKDecodeError ret = *owner->contents.err;
6740         ret.is_owned = false;
6741         return ret;
6742 }
6743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6744         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
6745         LDKDecodeError ret_var = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
6746         int64_t ret_ref = 0;
6747         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6748         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6749         return ret_ref;
6750 }
6751
6752 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
6753         LDKPhantomRouteHints ret = *owner->contents.result;
6754         ret.is_owned = false;
6755         return ret;
6756 }
6757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6758         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
6759         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
6760         int64_t ret_ref = 0;
6761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6762         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6763         return ret_ref;
6764 }
6765
6766 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
6767         LDKDecodeError ret = *owner->contents.err;
6768         ret.is_owned = false;
6769         return ret;
6770 }
6771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6772         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
6773         LDKDecodeError ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
6774         int64_t ret_ref = 0;
6775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6776         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6777         return ret_ref;
6778 }
6779
6780 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
6781         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
6782         for (size_t i = 0; i < ret.datalen; i++) {
6783                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
6784         }
6785         return ret;
6786 }
6787 typedef struct LDKWatch_JCalls {
6788         atomic_size_t refcnt;
6789         JavaVM *vm;
6790         jweak o;
6791         jmethodID watch_channel_meth;
6792         jmethodID update_channel_meth;
6793         jmethodID release_pending_monitor_events_meth;
6794 } LDKWatch_JCalls;
6795 static void LDKWatch_JCalls_free(void* this_arg) {
6796         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6797         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6798                 JNIEnv *env;
6799                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6800                 if (get_jenv_res == JNI_EDETACHED) {
6801                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6802                 } else {
6803                         DO_ASSERT(get_jenv_res == JNI_OK);
6804                 }
6805                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6806                 if (get_jenv_res == JNI_EDETACHED) {
6807                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6808                 }
6809                 FREE(j_calls);
6810         }
6811 }
6812 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
6813         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6814         JNIEnv *env;
6815         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6816         if (get_jenv_res == JNI_EDETACHED) {
6817                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6818         } else {
6819                 DO_ASSERT(get_jenv_res == JNI_OK);
6820         }
6821         LDKOutPoint funding_txo_var = funding_txo;
6822         int64_t funding_txo_ref = 0;
6823         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6824         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
6825         LDKChannelMonitor monitor_var = monitor;
6826         int64_t monitor_ref = 0;
6827         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
6828         monitor_ref = tag_ptr(monitor_var.inner, monitor_var.is_owned);
6829         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6830         CHECK(obj != NULL);
6831         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
6832         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6833                 (*env)->ExceptionDescribe(env);
6834                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
6835         }
6836         void* ret_ptr = untag_ptr(ret);
6837         CHECK_ACCESS(ret_ptr);
6838         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6839         FREE(untag_ptr(ret));
6840         if (get_jenv_res == JNI_EDETACHED) {
6841                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6842         }
6843         return ret_conv;
6844 }
6845 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
6846         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6847         JNIEnv *env;
6848         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6849         if (get_jenv_res == JNI_EDETACHED) {
6850                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6851         } else {
6852                 DO_ASSERT(get_jenv_res == JNI_OK);
6853         }
6854         LDKOutPoint funding_txo_var = funding_txo;
6855         int64_t funding_txo_ref = 0;
6856         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6857         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
6858         LDKChannelMonitorUpdate update_var = update;
6859         int64_t update_ref = 0;
6860         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
6861         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
6862         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6863         CHECK(obj != NULL);
6864         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
6865         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6866                 (*env)->ExceptionDescribe(env);
6867                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
6868         }
6869         void* ret_ptr = untag_ptr(ret);
6870         CHECK_ACCESS(ret_ptr);
6871         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
6872         FREE(untag_ptr(ret));
6873         if (get_jenv_res == JNI_EDETACHED) {
6874                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6875         }
6876         return ret_conv;
6877 }
6878 LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
6879         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6880         JNIEnv *env;
6881         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6882         if (get_jenv_res == JNI_EDETACHED) {
6883                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6884         } else {
6885                 DO_ASSERT(get_jenv_res == JNI_OK);
6886         }
6887         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6888         CHECK(obj != NULL);
6889         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
6890         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6891                 (*env)->ExceptionDescribe(env);
6892                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
6893         }
6894         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_constr;
6895         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
6896         if (ret_constr.datalen > 0)
6897                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
6898         else
6899                 ret_constr.data = NULL;
6900         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
6901         for (size_t x = 0; x < ret_constr.datalen; x++) {
6902                 int64_t ret_conv_49 = ret_vals[x];
6903                 void* ret_conv_49_ptr = untag_ptr(ret_conv_49);
6904                 CHECK_ACCESS(ret_conv_49_ptr);
6905                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ ret_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(ret_conv_49_ptr);
6906                 FREE(untag_ptr(ret_conv_49));
6907                 ret_constr.data[x] = ret_conv_49_conv;
6908         }
6909         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
6910         if (get_jenv_res == JNI_EDETACHED) {
6911                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6912         }
6913         return ret_constr;
6914 }
6915 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
6916         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
6917         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6918 }
6919 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
6920         jclass c = (*env)->GetObjectClass(env, o);
6921         CHECK(c != NULL);
6922         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
6923         atomic_init(&calls->refcnt, 1);
6924         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6925         calls->o = (*env)->NewWeakGlobalRef(env, o);
6926         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
6927         CHECK(calls->watch_channel_meth != NULL);
6928         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
6929         CHECK(calls->update_channel_meth != NULL);
6930         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
6931         CHECK(calls->release_pending_monitor_events_meth != NULL);
6932
6933         LDKWatch ret = {
6934                 .this_arg = (void*) calls,
6935                 .watch_channel = watch_channel_LDKWatch_jcall,
6936                 .update_channel = update_channel_LDKWatch_jcall,
6937                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
6938                 .free = LDKWatch_JCalls_free,
6939         };
6940         return ret;
6941 }
6942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
6943         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
6944         *res_ptr = LDKWatch_init(env, clz, o);
6945         return tag_ptr(res_ptr, true);
6946 }
6947 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) {
6948         void* this_arg_ptr = untag_ptr(this_arg);
6949         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6950         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6951         LDKOutPoint funding_txo_conv;
6952         funding_txo_conv.inner = untag_ptr(funding_txo);
6953         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
6954         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6955         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6956         LDKChannelMonitor monitor_conv;
6957         monitor_conv.inner = untag_ptr(monitor);
6958         monitor_conv.is_owned = ptr_is_owned(monitor);
6959         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
6960         monitor_conv = ChannelMonitor_clone(&monitor_conv);
6961         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6962         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
6963         return tag_ptr(ret_conv, true);
6964 }
6965
6966 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) {
6967         void* this_arg_ptr = untag_ptr(this_arg);
6968         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6969         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6970         LDKOutPoint funding_txo_conv;
6971         funding_txo_conv.inner = untag_ptr(funding_txo);
6972         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
6973         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
6974         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6975         LDKChannelMonitorUpdate update_conv;
6976         update_conv.inner = untag_ptr(update);
6977         update_conv.is_owned = ptr_is_owned(update);
6978         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
6979         update_conv = ChannelMonitorUpdate_clone(&update_conv);
6980         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
6981         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
6982         return tag_ptr(ret_conv, true);
6983 }
6984
6985 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
6986         void* this_arg_ptr = untag_ptr(this_arg);
6987         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6988         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
6989         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
6990         int64_tArray ret_arr = NULL;
6991         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6992         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6993         for (size_t x = 0; x < ret_var.datalen; x++) {
6994                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv_49_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
6995                 *ret_conv_49_conv = ret_var.data[x];
6996                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
6997         }
6998         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6999         FREE(ret_var.data);
7000         return ret_arr;
7001 }
7002
7003 typedef struct LDKBroadcasterInterface_JCalls {
7004         atomic_size_t refcnt;
7005         JavaVM *vm;
7006         jweak o;
7007         jmethodID broadcast_transaction_meth;
7008 } LDKBroadcasterInterface_JCalls;
7009 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
7010         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
7011         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7012                 JNIEnv *env;
7013                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7014                 if (get_jenv_res == JNI_EDETACHED) {
7015                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7016                 } else {
7017                         DO_ASSERT(get_jenv_res == JNI_OK);
7018                 }
7019                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7020                 if (get_jenv_res == JNI_EDETACHED) {
7021                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7022                 }
7023                 FREE(j_calls);
7024         }
7025 }
7026 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
7027         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
7028         JNIEnv *env;
7029         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7030         if (get_jenv_res == JNI_EDETACHED) {
7031                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7032         } else {
7033                 DO_ASSERT(get_jenv_res == JNI_OK);
7034         }
7035         LDKTransaction tx_var = tx;
7036         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
7037         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
7038         Transaction_free(tx_var);
7039         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7040         CHECK(obj != NULL);
7041         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
7042         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7043                 (*env)->ExceptionDescribe(env);
7044                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
7045         }
7046         if (get_jenv_res == JNI_EDETACHED) {
7047                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7048         }
7049 }
7050 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
7051         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
7052         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7053 }
7054 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
7055         jclass c = (*env)->GetObjectClass(env, o);
7056         CHECK(c != NULL);
7057         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
7058         atomic_init(&calls->refcnt, 1);
7059         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7060         calls->o = (*env)->NewWeakGlobalRef(env, o);
7061         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
7062         CHECK(calls->broadcast_transaction_meth != NULL);
7063
7064         LDKBroadcasterInterface ret = {
7065                 .this_arg = (void*) calls,
7066                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
7067                 .free = LDKBroadcasterInterface_JCalls_free,
7068         };
7069         return ret;
7070 }
7071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
7072         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
7073         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
7074         return tag_ptr(res_ptr, true);
7075 }
7076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
7077         void* this_arg_ptr = untag_ptr(this_arg);
7078         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7079         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
7080         LDKTransaction tx_ref;
7081         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
7082         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
7083         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
7084         tx_ref.data_is_owned = true;
7085         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
7086 }
7087
7088 typedef struct LDKKeysInterface_JCalls {
7089         atomic_size_t refcnt;
7090         JavaVM *vm;
7091         jweak o;
7092         jmethodID get_node_secret_meth;
7093         jmethodID ecdh_meth;
7094         jmethodID get_destination_script_meth;
7095         jmethodID get_shutdown_scriptpubkey_meth;
7096         jmethodID get_channel_signer_meth;
7097         jmethodID get_secure_random_bytes_meth;
7098         jmethodID read_chan_signer_meth;
7099         jmethodID sign_invoice_meth;
7100         jmethodID get_inbound_payment_key_material_meth;
7101 } LDKKeysInterface_JCalls;
7102 static void LDKKeysInterface_JCalls_free(void* this_arg) {
7103         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7104         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7105                 JNIEnv *env;
7106                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7107                 if (get_jenv_res == JNI_EDETACHED) {
7108                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7109                 } else {
7110                         DO_ASSERT(get_jenv_res == JNI_OK);
7111                 }
7112                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7113                 if (get_jenv_res == JNI_EDETACHED) {
7114                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7115                 }
7116                 FREE(j_calls);
7117         }
7118 }
7119 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
7120         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7121         JNIEnv *env;
7122         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7123         if (get_jenv_res == JNI_EDETACHED) {
7124                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7125         } else {
7126                 DO_ASSERT(get_jenv_res == JNI_OK);
7127         }
7128         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
7129         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7130         CHECK(obj != NULL);
7131         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_secret_meth, recipient_conv);
7132         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7133                 (*env)->ExceptionDescribe(env);
7134                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
7135         }
7136         void* ret_ptr = untag_ptr(ret);
7137         CHECK_ACCESS(ret_ptr);
7138         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
7139         FREE(untag_ptr(ret));
7140         if (get_jenv_res == JNI_EDETACHED) {
7141                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7142         }
7143         return ret_conv;
7144 }
7145 LDKCResult_SharedSecretNoneZ ecdh_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient, LDKPublicKey other_key, LDKCOption_ScalarZ tweak) {
7146         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7147         JNIEnv *env;
7148         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7149         if (get_jenv_res == JNI_EDETACHED) {
7150                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7151         } else {
7152                 DO_ASSERT(get_jenv_res == JNI_OK);
7153         }
7154         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
7155         int8_tArray other_key_arr = (*env)->NewByteArray(env, 33);
7156         (*env)->SetByteArrayRegion(env, other_key_arr, 0, 33, other_key.compressed_form);
7157         LDKCOption_ScalarZ *tweak_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
7158         *tweak_copy = tweak;
7159         int64_t tweak_ref = tag_ptr(tweak_copy, true);
7160         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7161         CHECK(obj != NULL);
7162         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->ecdh_meth, recipient_conv, other_key_arr, tweak_ref);
7163         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7164                 (*env)->ExceptionDescribe(env);
7165                 (*env)->FatalError(env, "A call to ecdh in LDKKeysInterface from rust threw an exception.");
7166         }
7167         void* ret_ptr = untag_ptr(ret);
7168         CHECK_ACCESS(ret_ptr);
7169         LDKCResult_SharedSecretNoneZ ret_conv = *(LDKCResult_SharedSecretNoneZ*)(ret_ptr);
7170         FREE(untag_ptr(ret));
7171         if (get_jenv_res == JNI_EDETACHED) {
7172                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7173         }
7174         return ret_conv;
7175 }
7176 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
7177         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7178         JNIEnv *env;
7179         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7180         if (get_jenv_res == JNI_EDETACHED) {
7181                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7182         } else {
7183                 DO_ASSERT(get_jenv_res == JNI_OK);
7184         }
7185         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7186         CHECK(obj != NULL);
7187         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
7188         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7189                 (*env)->ExceptionDescribe(env);
7190                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
7191         }
7192         LDKCVec_u8Z ret_ref;
7193         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
7194         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
7195         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
7196         if (get_jenv_res == JNI_EDETACHED) {
7197                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7198         }
7199         return ret_ref;
7200 }
7201 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
7202         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7203         JNIEnv *env;
7204         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7205         if (get_jenv_res == JNI_EDETACHED) {
7206                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7207         } else {
7208                 DO_ASSERT(get_jenv_res == JNI_OK);
7209         }
7210         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7211         CHECK(obj != NULL);
7212         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
7213         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7214                 (*env)->ExceptionDescribe(env);
7215                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
7216         }
7217         LDKShutdownScript ret_conv;
7218         ret_conv.inner = untag_ptr(ret);
7219         ret_conv.is_owned = ptr_is_owned(ret);
7220         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
7221         if (get_jenv_res == JNI_EDETACHED) {
7222                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7223         }
7224         return ret_conv;
7225 }
7226 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
7227         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7228         JNIEnv *env;
7229         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7230         if (get_jenv_res == JNI_EDETACHED) {
7231                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7232         } else {
7233                 DO_ASSERT(get_jenv_res == JNI_OK);
7234         }
7235         jboolean inbound_conv = inbound;
7236         int64_t channel_value_satoshis_conv = channel_value_satoshis;
7237         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7238         CHECK(obj != NULL);
7239         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound_conv, channel_value_satoshis_conv);
7240         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7241                 (*env)->ExceptionDescribe(env);
7242                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
7243         }
7244         void* ret_ptr = untag_ptr(ret);
7245         CHECK_ACCESS(ret_ptr);
7246         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
7247         FREE(untag_ptr(ret));
7248         if (get_jenv_res == JNI_EDETACHED) {
7249                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7250         }
7251         return ret_conv;
7252 }
7253 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
7254         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7255         JNIEnv *env;
7256         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7257         if (get_jenv_res == JNI_EDETACHED) {
7258                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7259         } else {
7260                 DO_ASSERT(get_jenv_res == JNI_OK);
7261         }
7262         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7263         CHECK(obj != NULL);
7264         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
7265         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7266                 (*env)->ExceptionDescribe(env);
7267                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
7268         }
7269         LDKThirtyTwoBytes ret_ref;
7270         CHECK((*env)->GetArrayLength(env, ret) == 32);
7271         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
7272         if (get_jenv_res == JNI_EDETACHED) {
7273                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7274         }
7275         return ret_ref;
7276 }
7277 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
7278         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7279         JNIEnv *env;
7280         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7281         if (get_jenv_res == JNI_EDETACHED) {
7282                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7283         } else {
7284                 DO_ASSERT(get_jenv_res == JNI_OK);
7285         }
7286         LDKu8slice reader_var = reader;
7287         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
7288         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
7289         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7290         CHECK(obj != NULL);
7291         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
7292         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7293                 (*env)->ExceptionDescribe(env);
7294                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
7295         }
7296         void* ret_ptr = untag_ptr(ret);
7297         CHECK_ACCESS(ret_ptr);
7298         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
7299         FREE(untag_ptr(ret));
7300         if (get_jenv_res == JNI_EDETACHED) {
7301                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7302         }
7303         return ret_conv;
7304 }
7305 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_u5Z invoice_data, LDKRecipient receipient) {
7306         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7307         JNIEnv *env;
7308         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7309         if (get_jenv_res == JNI_EDETACHED) {
7310                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7311         } else {
7312                 DO_ASSERT(get_jenv_res == JNI_OK);
7313         }
7314         LDKu8slice hrp_bytes_var = hrp_bytes;
7315         int8_tArray hrp_bytes_arr = (*env)->NewByteArray(env, hrp_bytes_var.datalen);
7316         (*env)->SetByteArrayRegion(env, hrp_bytes_arr, 0, hrp_bytes_var.datalen, hrp_bytes_var.data);
7317         LDKCVec_u5Z invoice_data_var = invoice_data;
7318         jobjectArray invoice_data_arr = NULL;
7319         invoice_data_arr = (*env)->NewByteArray(env, invoice_data_var.datalen);
7320         int8_t *invoice_data_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, invoice_data_arr, NULL);
7321         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
7322                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
7323                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
7324         }
7325         (*env)->ReleasePrimitiveArrayCritical(env, invoice_data_arr, invoice_data_arr_ptr, 0);
7326         FREE(invoice_data_var.data);
7327         jclass receipient_conv = LDKRecipient_to_java(env, receipient);
7328         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7329         CHECK(obj != NULL);
7330         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, hrp_bytes_arr, invoice_data_arr, receipient_conv);
7331         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7332                 (*env)->ExceptionDescribe(env);
7333                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
7334         }
7335         void* ret_ptr = untag_ptr(ret);
7336         CHECK_ACCESS(ret_ptr);
7337         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
7338         FREE(untag_ptr(ret));
7339         if (get_jenv_res == JNI_EDETACHED) {
7340                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7341         }
7342         return ret_conv;
7343 }
7344 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
7345         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7346         JNIEnv *env;
7347         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7348         if (get_jenv_res == JNI_EDETACHED) {
7349                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7350         } else {
7351                 DO_ASSERT(get_jenv_res == JNI_OK);
7352         }
7353         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7354         CHECK(obj != NULL);
7355         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
7356         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7357                 (*env)->ExceptionDescribe(env);
7358                 (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKKeysInterface from rust threw an exception.");
7359         }
7360         LDKThirtyTwoBytes ret_ref;
7361         CHECK((*env)->GetArrayLength(env, ret) == 32);
7362         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
7363         if (get_jenv_res == JNI_EDETACHED) {
7364                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7365         }
7366         return ret_ref;
7367 }
7368 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
7369         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
7370         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7371 }
7372 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
7373         jclass c = (*env)->GetObjectClass(env, o);
7374         CHECK(c != NULL);
7375         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
7376         atomic_init(&calls->refcnt, 1);
7377         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7378         calls->o = (*env)->NewWeakGlobalRef(env, o);
7379         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "(Lorg/ldk/enums/Recipient;)J");
7380         CHECK(calls->get_node_secret_meth != NULL);
7381         calls->ecdh_meth = (*env)->GetMethodID(env, c, "ecdh", "(Lorg/ldk/enums/Recipient;[BJ)J");
7382         CHECK(calls->ecdh_meth != NULL);
7383         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
7384         CHECK(calls->get_destination_script_meth != NULL);
7385         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
7386         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
7387         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
7388         CHECK(calls->get_channel_signer_meth != NULL);
7389         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
7390         CHECK(calls->get_secure_random_bytes_meth != NULL);
7391         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
7392         CHECK(calls->read_chan_signer_meth != NULL);
7393         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B[BLorg/ldk/enums/Recipient;)J");
7394         CHECK(calls->sign_invoice_meth != NULL);
7395         calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
7396         CHECK(calls->get_inbound_payment_key_material_meth != NULL);
7397
7398         LDKKeysInterface ret = {
7399                 .this_arg = (void*) calls,
7400                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
7401                 .ecdh = ecdh_LDKKeysInterface_jcall,
7402                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
7403                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
7404                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
7405                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
7406                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
7407                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
7408                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
7409                 .free = LDKKeysInterface_JCalls_free,
7410         };
7411         return ret;
7412 }
7413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
7414         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
7415         *res_ptr = LDKKeysInterface_init(env, clz, o);
7416         return tag_ptr(res_ptr, true);
7417 }
7418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
7419         void* this_arg_ptr = untag_ptr(this_arg);
7420         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7421         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7422         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
7423         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
7424         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
7425         return tag_ptr(ret_conv, true);
7426 }
7427
7428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1ecdh(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient, int8_tArray other_key, int64_t tweak) {
7429         void* this_arg_ptr = untag_ptr(this_arg);
7430         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7431         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7432         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
7433         LDKPublicKey other_key_ref;
7434         CHECK((*env)->GetArrayLength(env, other_key) == 33);
7435         (*env)->GetByteArrayRegion(env, other_key, 0, 33, other_key_ref.compressed_form);
7436         void* tweak_ptr = untag_ptr(tweak);
7437         CHECK_ACCESS(tweak_ptr);
7438         LDKCOption_ScalarZ tweak_conv = *(LDKCOption_ScalarZ*)(tweak_ptr);
7439         // WARNING: we may need a move here but no clone is available for LDKCOption_ScalarZ
7440         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
7441         *ret_conv = (this_arg_conv->ecdh)(this_arg_conv->this_arg, recipient_conv, other_key_ref, tweak_conv);
7442         return tag_ptr(ret_conv, true);
7443 }
7444
7445 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
7446         void* this_arg_ptr = untag_ptr(this_arg);
7447         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7448         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7449         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
7450         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7451         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7452         CVec_u8Z_free(ret_var);
7453         return ret_arr;
7454 }
7455
7456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
7457         void* this_arg_ptr = untag_ptr(this_arg);
7458         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7459         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7460         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
7461         int64_t ret_ref = 0;
7462         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7463         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7464         return ret_ref;
7465 }
7466
7467 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) {
7468         void* this_arg_ptr = untag_ptr(this_arg);
7469         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7470         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7471         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
7472         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
7473         return tag_ptr(ret_ret, true);
7474 }
7475
7476 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
7477         void* this_arg_ptr = untag_ptr(this_arg);
7478         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7479         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7480         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7481         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
7482         return ret_arr;
7483 }
7484
7485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
7486         void* this_arg_ptr = untag_ptr(this_arg);
7487         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7488         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7489         LDKu8slice reader_ref;
7490         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
7491         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
7492         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7493         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
7494         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
7495         return tag_ptr(ret_conv, true);
7496 }
7497
7498 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) {
7499         void* this_arg_ptr = untag_ptr(this_arg);
7500         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7501         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7502         LDKu8slice hrp_bytes_ref;
7503         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
7504         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
7505         LDKCVec_u5Z invoice_data_constr;
7506         invoice_data_constr.datalen = (*env)->GetArrayLength(env, invoice_data);
7507         if (invoice_data_constr.datalen > 0)
7508                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
7509         else
7510                 invoice_data_constr.data = NULL;
7511         int8_t* invoice_data_vals = (*env)->GetByteArrayElements (env, invoice_data, NULL);
7512         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
7513                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
7514                 
7515                 invoice_data_constr.data[h] = (LDKu5){ ._0 = invoice_data_conv_7 };
7516         }
7517         (*env)->ReleaseByteArrayElements(env, invoice_data, invoice_data_vals, 0);
7518         LDKRecipient receipient_conv = LDKRecipient_from_java(env, receipient);
7519         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7520         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
7521         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
7522         return tag_ptr(ret_conv, true);
7523 }
7524
7525 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
7526         void* this_arg_ptr = untag_ptr(this_arg);
7527         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7528         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7529         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7530         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
7531         return ret_arr;
7532 }
7533
7534 typedef struct LDKFeeEstimator_JCalls {
7535         atomic_size_t refcnt;
7536         JavaVM *vm;
7537         jweak o;
7538         jmethodID get_est_sat_per_1000_weight_meth;
7539 } LDKFeeEstimator_JCalls;
7540 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
7541         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
7542         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7543                 JNIEnv *env;
7544                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7545                 if (get_jenv_res == JNI_EDETACHED) {
7546                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7547                 } else {
7548                         DO_ASSERT(get_jenv_res == JNI_OK);
7549                 }
7550                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7551                 if (get_jenv_res == JNI_EDETACHED) {
7552                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7553                 }
7554                 FREE(j_calls);
7555         }
7556 }
7557 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
7558         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
7559         JNIEnv *env;
7560         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7561         if (get_jenv_res == JNI_EDETACHED) {
7562                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7563         } else {
7564                 DO_ASSERT(get_jenv_res == JNI_OK);
7565         }
7566         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
7567         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7568         CHECK(obj != NULL);
7569         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
7570         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7571                 (*env)->ExceptionDescribe(env);
7572                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
7573         }
7574         if (get_jenv_res == JNI_EDETACHED) {
7575                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7576         }
7577         return ret;
7578 }
7579 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
7580         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
7581         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7582 }
7583 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
7584         jclass c = (*env)->GetObjectClass(env, o);
7585         CHECK(c != NULL);
7586         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
7587         atomic_init(&calls->refcnt, 1);
7588         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7589         calls->o = (*env)->NewWeakGlobalRef(env, o);
7590         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
7591         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
7592
7593         LDKFeeEstimator ret = {
7594                 .this_arg = (void*) calls,
7595                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
7596                 .free = LDKFeeEstimator_JCalls_free,
7597         };
7598         return ret;
7599 }
7600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
7601         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
7602         *res_ptr = LDKFeeEstimator_init(env, clz, o);
7603         return tag_ptr(res_ptr, true);
7604 }
7605 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) {
7606         void* this_arg_ptr = untag_ptr(this_arg);
7607         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7608         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
7609         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
7610         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
7611         return ret_conv;
7612 }
7613
7614 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
7615         return ThirtyTwoBytes_clone(&owner->a);
7616 }
7617 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7618         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)untag_ptr(owner);
7619         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7620         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data);
7621         return ret_arr;
7622 }
7623
7624 static inline struct LDKChannelManager C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
7625         LDKChannelManager ret = owner->b;
7626         ret.is_owned = false;
7627         return ret;
7628 }
7629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7630         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)untag_ptr(owner);
7631         LDKChannelManager ret_var = C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
7632         int64_t ret_ref = 0;
7633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7634         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7635         return ret_ref;
7636 }
7637
7638 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
7639 CHECK(owner->result_ok);
7640         return &*owner->contents.result;
7641 }
7642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7643         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(owner);
7644         int64_t ret_ret = tag_ptr(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv), false);
7645         return ret_ret;
7646 }
7647
7648 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
7649         LDKDecodeError ret = *owner->contents.err;
7650         ret.is_owned = false;
7651         return ret;
7652 }
7653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7654         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(owner);
7655         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
7656         int64_t ret_ref = 0;
7657         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7658         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7659         return ret_ref;
7660 }
7661
7662 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
7663         LDKChannelConfig ret = *owner->contents.result;
7664         ret.is_owned = false;
7665         return ret;
7666 }
7667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7668         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
7669         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
7670         int64_t ret_ref = 0;
7671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7672         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7673         return ret_ref;
7674 }
7675
7676 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
7677         LDKDecodeError ret = *owner->contents.err;
7678         ret.is_owned = false;
7679         return ret;
7680 }
7681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7682         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
7683         LDKDecodeError ret_var = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
7684         int64_t ret_ref = 0;
7685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7686         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7687         return ret_ref;
7688 }
7689
7690 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
7691         LDKOutPoint ret = *owner->contents.result;
7692         ret.is_owned = false;
7693         return ret;
7694 }
7695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7696         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
7697         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
7698         int64_t ret_ref = 0;
7699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7700         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7701         return ret_ref;
7702 }
7703
7704 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
7705         LDKDecodeError ret = *owner->contents.err;
7706         ret.is_owned = false;
7707         return ret;
7708 }
7709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7710         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
7711         LDKDecodeError ret_var = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
7712         int64_t ret_ref = 0;
7713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7714         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7715         return ret_ref;
7716 }
7717
7718 typedef struct LDKType_JCalls {
7719         atomic_size_t refcnt;
7720         JavaVM *vm;
7721         jweak o;
7722         jmethodID type_id_meth;
7723         jmethodID debug_str_meth;
7724         jmethodID write_meth;
7725 } LDKType_JCalls;
7726 static void LDKType_JCalls_free(void* this_arg) {
7727         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7728         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7729                 JNIEnv *env;
7730                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7731                 if (get_jenv_res == JNI_EDETACHED) {
7732                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7733                 } else {
7734                         DO_ASSERT(get_jenv_res == JNI_OK);
7735                 }
7736                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7737                 if (get_jenv_res == JNI_EDETACHED) {
7738                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7739                 }
7740                 FREE(j_calls);
7741         }
7742 }
7743 uint16_t type_id_LDKType_jcall(const void* this_arg) {
7744         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7745         JNIEnv *env;
7746         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7747         if (get_jenv_res == JNI_EDETACHED) {
7748                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7749         } else {
7750                 DO_ASSERT(get_jenv_res == JNI_OK);
7751         }
7752         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7753         CHECK(obj != NULL);
7754         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
7755         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7756                 (*env)->ExceptionDescribe(env);
7757                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
7758         }
7759         if (get_jenv_res == JNI_EDETACHED) {
7760                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7761         }
7762         return ret;
7763 }
7764 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
7765         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7766         JNIEnv *env;
7767         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7768         if (get_jenv_res == JNI_EDETACHED) {
7769                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7770         } else {
7771                 DO_ASSERT(get_jenv_res == JNI_OK);
7772         }
7773         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7774         CHECK(obj != NULL);
7775         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
7776         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7777                 (*env)->ExceptionDescribe(env);
7778                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
7779         }
7780         LDKStr ret_conv = java_to_owned_str(env, ret);
7781         if (get_jenv_res == JNI_EDETACHED) {
7782                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7783         }
7784         return ret_conv;
7785 }
7786 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
7787         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7788         JNIEnv *env;
7789         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7790         if (get_jenv_res == JNI_EDETACHED) {
7791                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7792         } else {
7793                 DO_ASSERT(get_jenv_res == JNI_OK);
7794         }
7795         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7796         CHECK(obj != NULL);
7797         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
7798         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7799                 (*env)->ExceptionDescribe(env);
7800                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
7801         }
7802         LDKCVec_u8Z ret_ref;
7803         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
7804         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
7805         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
7806         if (get_jenv_res == JNI_EDETACHED) {
7807                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7808         }
7809         return ret_ref;
7810 }
7811 static void LDKType_JCalls_cloned(LDKType* new_obj) {
7812         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
7813         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7814 }
7815 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
7816         jclass c = (*env)->GetObjectClass(env, o);
7817         CHECK(c != NULL);
7818         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
7819         atomic_init(&calls->refcnt, 1);
7820         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7821         calls->o = (*env)->NewWeakGlobalRef(env, o);
7822         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
7823         CHECK(calls->type_id_meth != NULL);
7824         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
7825         CHECK(calls->debug_str_meth != NULL);
7826         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
7827         CHECK(calls->write_meth != NULL);
7828
7829         LDKType ret = {
7830                 .this_arg = (void*) calls,
7831                 .type_id = type_id_LDKType_jcall,
7832                 .debug_str = debug_str_LDKType_jcall,
7833                 .write = write_LDKType_jcall,
7834                 .cloned = LDKType_JCalls_cloned,
7835                 .free = LDKType_JCalls_free,
7836         };
7837         return ret;
7838 }
7839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
7840         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
7841         *res_ptr = LDKType_init(env, clz, o);
7842         return tag_ptr(res_ptr, true);
7843 }
7844 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
7845         void* this_arg_ptr = untag_ptr(this_arg);
7846         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7847         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7848         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
7849         return ret_conv;
7850 }
7851
7852 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
7853         void* this_arg_ptr = untag_ptr(this_arg);
7854         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7855         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7856         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
7857         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
7858         Str_free(ret_str);
7859         return ret_conv;
7860 }
7861
7862 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
7863         void* this_arg_ptr = untag_ptr(this_arg);
7864         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7865         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
7866         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
7867         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7868         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7869         CVec_u8Z_free(ret_var);
7870         return ret_arr;
7871 }
7872
7873 static jclass LDKCOption_TypeZ_Some_class = NULL;
7874 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
7875 static jclass LDKCOption_TypeZ_None_class = NULL;
7876 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
7877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
7878         LDKCOption_TypeZ_Some_class =
7879                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
7880         CHECK(LDKCOption_TypeZ_Some_class != NULL);
7881         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
7882         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
7883         LDKCOption_TypeZ_None_class =
7884                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
7885         CHECK(LDKCOption_TypeZ_None_class != NULL);
7886         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
7887         CHECK(LDKCOption_TypeZ_None_meth != NULL);
7888 }
7889 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7890         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)untag_ptr(ptr);
7891         switch(obj->tag) {
7892                 case LDKCOption_TypeZ_Some: {
7893                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
7894                         *some_ret = Type_clone(&obj->some);
7895                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, tag_ptr(some_ret, true));
7896                 }
7897                 case LDKCOption_TypeZ_None: {
7898                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
7899                 }
7900                 default: abort();
7901         }
7902 }
7903 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7904 CHECK(owner->result_ok);
7905         return COption_TypeZ_clone(&*owner->contents.result);
7906 }
7907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7908         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
7909         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
7910         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
7911         int64_t ret_ref = tag_ptr(ret_copy, true);
7912         return ret_ref;
7913 }
7914
7915 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
7916         LDKDecodeError ret = *owner->contents.err;
7917         ret.is_owned = false;
7918         return ret;
7919 }
7920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7921         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
7922         LDKDecodeError ret_var = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
7923         int64_t ret_ref = 0;
7924         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7925         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7926         return ret_ref;
7927 }
7928
7929 static jclass LDKPaymentError_Invoice_class = NULL;
7930 static jmethodID LDKPaymentError_Invoice_meth = NULL;
7931 static jclass LDKPaymentError_Routing_class = NULL;
7932 static jmethodID LDKPaymentError_Routing_meth = NULL;
7933 static jclass LDKPaymentError_Sending_class = NULL;
7934 static jmethodID LDKPaymentError_Sending_meth = NULL;
7935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
7936         LDKPaymentError_Invoice_class =
7937                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
7938         CHECK(LDKPaymentError_Invoice_class != NULL);
7939         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
7940         CHECK(LDKPaymentError_Invoice_meth != NULL);
7941         LDKPaymentError_Routing_class =
7942                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Routing"));
7943         CHECK(LDKPaymentError_Routing_class != NULL);
7944         LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
7945         CHECK(LDKPaymentError_Routing_meth != NULL);
7946         LDKPaymentError_Sending_class =
7947                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
7948         CHECK(LDKPaymentError_Sending_class != NULL);
7949         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
7950         CHECK(LDKPaymentError_Sending_meth != NULL);
7951 }
7952 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7953         LDKPaymentError *obj = (LDKPaymentError*)untag_ptr(ptr);
7954         switch(obj->tag) {
7955                 case LDKPaymentError_Invoice: {
7956                         LDKStr invoice_str = obj->invoice;
7957                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
7958                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
7959                 }
7960                 case LDKPaymentError_Routing: {
7961                         LDKLightningError routing_var = obj->routing;
7962                         int64_t routing_ref = 0;
7963                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
7964                         routing_ref = tag_ptr(routing_var.inner, false);
7965                         return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
7966                 }
7967                 case LDKPaymentError_Sending: {
7968                         int64_t sending_ref = tag_ptr(&obj->sending, false);
7969                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
7970                 }
7971                 default: abort();
7972         }
7973 }
7974 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
7975 CHECK(owner->result_ok);
7976         return ThirtyTwoBytes_clone(&*owner->contents.result);
7977 }
7978 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7979         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(owner);
7980         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7981         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data);
7982         return ret_arr;
7983 }
7984
7985 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
7986 CHECK(!owner->result_ok);
7987         return PaymentError_clone(&*owner->contents.err);
7988 }
7989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7990         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(owner);
7991         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
7992         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
7993         int64_t ret_ref = tag_ptr(ret_copy, true);
7994         return ret_ref;
7995 }
7996
7997 static inline struct LDKInFlightHtlcs CResult_InFlightHtlcsDecodeErrorZ_get_ok(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR owner){
7998         LDKInFlightHtlcs ret = *owner->contents.result;
7999         ret.is_owned = false;
8000         return ret;
8001 }
8002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8003         LDKCResult_InFlightHtlcsDecodeErrorZ* owner_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(owner);
8004         LDKInFlightHtlcs ret_var = CResult_InFlightHtlcsDecodeErrorZ_get_ok(owner_conv);
8005         int64_t ret_ref = 0;
8006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8007         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8008         return ret_ref;
8009 }
8010
8011 static inline struct LDKDecodeError CResult_InFlightHtlcsDecodeErrorZ_get_err(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR owner){
8012         LDKDecodeError ret = *owner->contents.err;
8013         ret.is_owned = false;
8014         return ret;
8015 }
8016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8017         LDKCResult_InFlightHtlcsDecodeErrorZ* owner_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(owner);
8018         LDKDecodeError ret_var = CResult_InFlightHtlcsDecodeErrorZ_get_err(owner_conv);
8019         int64_t ret_ref = 0;
8020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8021         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8022         return ret_ref;
8023 }
8024
8025 static jclass LDKParseError_Bech32Error_class = NULL;
8026 static jmethodID LDKParseError_Bech32Error_meth = NULL;
8027 static jclass LDKParseError_ParseAmountError_class = NULL;
8028 static jmethodID LDKParseError_ParseAmountError_meth = NULL;
8029 static jclass LDKParseError_MalformedSignature_class = NULL;
8030 static jmethodID LDKParseError_MalformedSignature_meth = NULL;
8031 static jclass LDKParseError_BadPrefix_class = NULL;
8032 static jmethodID LDKParseError_BadPrefix_meth = NULL;
8033 static jclass LDKParseError_UnknownCurrency_class = NULL;
8034 static jmethodID LDKParseError_UnknownCurrency_meth = NULL;
8035 static jclass LDKParseError_UnknownSiPrefix_class = NULL;
8036 static jmethodID LDKParseError_UnknownSiPrefix_meth = NULL;
8037 static jclass LDKParseError_MalformedHRP_class = NULL;
8038 static jmethodID LDKParseError_MalformedHRP_meth = NULL;
8039 static jclass LDKParseError_TooShortDataPart_class = NULL;
8040 static jmethodID LDKParseError_TooShortDataPart_meth = NULL;
8041 static jclass LDKParseError_UnexpectedEndOfTaggedFields_class = NULL;
8042 static jmethodID LDKParseError_UnexpectedEndOfTaggedFields_meth = NULL;
8043 static jclass LDKParseError_DescriptionDecodeError_class = NULL;
8044 static jmethodID LDKParseError_DescriptionDecodeError_meth = NULL;
8045 static jclass LDKParseError_PaddingError_class = NULL;
8046 static jmethodID LDKParseError_PaddingError_meth = NULL;
8047 static jclass LDKParseError_IntegerOverflowError_class = NULL;
8048 static jmethodID LDKParseError_IntegerOverflowError_meth = NULL;
8049 static jclass LDKParseError_InvalidSegWitProgramLength_class = NULL;
8050 static jmethodID LDKParseError_InvalidSegWitProgramLength_meth = NULL;
8051 static jclass LDKParseError_InvalidPubKeyHashLength_class = NULL;
8052 static jmethodID LDKParseError_InvalidPubKeyHashLength_meth = NULL;
8053 static jclass LDKParseError_InvalidScriptHashLength_class = NULL;
8054 static jmethodID LDKParseError_InvalidScriptHashLength_meth = NULL;
8055 static jclass LDKParseError_InvalidRecoveryId_class = NULL;
8056 static jmethodID LDKParseError_InvalidRecoveryId_meth = NULL;
8057 static jclass LDKParseError_InvalidSliceLength_class = NULL;
8058 static jmethodID LDKParseError_InvalidSliceLength_meth = NULL;
8059 static jclass LDKParseError_Skip_class = NULL;
8060 static jmethodID LDKParseError_Skip_meth = NULL;
8061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseError_init (JNIEnv *env, jclass clz) {
8062         LDKParseError_Bech32Error_class =
8063                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Bech32Error"));
8064         CHECK(LDKParseError_Bech32Error_class != NULL);
8065         LDKParseError_Bech32Error_meth = (*env)->GetMethodID(env, LDKParseError_Bech32Error_class, "<init>", "(J)V");
8066         CHECK(LDKParseError_Bech32Error_meth != NULL);
8067         LDKParseError_ParseAmountError_class =
8068                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$ParseAmountError"));
8069         CHECK(LDKParseError_ParseAmountError_class != NULL);
8070         LDKParseError_ParseAmountError_meth = (*env)->GetMethodID(env, LDKParseError_ParseAmountError_class, "<init>", "(I)V");
8071         CHECK(LDKParseError_ParseAmountError_meth != NULL);
8072         LDKParseError_MalformedSignature_class =
8073                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedSignature"));
8074         CHECK(LDKParseError_MalformedSignature_class != NULL);
8075         LDKParseError_MalformedSignature_meth = (*env)->GetMethodID(env, LDKParseError_MalformedSignature_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
8076         CHECK(LDKParseError_MalformedSignature_meth != NULL);
8077         LDKParseError_BadPrefix_class =
8078                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$BadPrefix"));
8079         CHECK(LDKParseError_BadPrefix_class != NULL);
8080         LDKParseError_BadPrefix_meth = (*env)->GetMethodID(env, LDKParseError_BadPrefix_class, "<init>", "()V");
8081         CHECK(LDKParseError_BadPrefix_meth != NULL);
8082         LDKParseError_UnknownCurrency_class =
8083                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownCurrency"));
8084         CHECK(LDKParseError_UnknownCurrency_class != NULL);
8085         LDKParseError_UnknownCurrency_meth = (*env)->GetMethodID(env, LDKParseError_UnknownCurrency_class, "<init>", "()V");
8086         CHECK(LDKParseError_UnknownCurrency_meth != NULL);
8087         LDKParseError_UnknownSiPrefix_class =
8088                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownSiPrefix"));
8089         CHECK(LDKParseError_UnknownSiPrefix_class != NULL);
8090         LDKParseError_UnknownSiPrefix_meth = (*env)->GetMethodID(env, LDKParseError_UnknownSiPrefix_class, "<init>", "()V");
8091         CHECK(LDKParseError_UnknownSiPrefix_meth != NULL);
8092         LDKParseError_MalformedHRP_class =
8093                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedHRP"));
8094         CHECK(LDKParseError_MalformedHRP_class != NULL);
8095         LDKParseError_MalformedHRP_meth = (*env)->GetMethodID(env, LDKParseError_MalformedHRP_class, "<init>", "()V");
8096         CHECK(LDKParseError_MalformedHRP_meth != NULL);
8097         LDKParseError_TooShortDataPart_class =
8098                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$TooShortDataPart"));
8099         CHECK(LDKParseError_TooShortDataPart_class != NULL);
8100         LDKParseError_TooShortDataPart_meth = (*env)->GetMethodID(env, LDKParseError_TooShortDataPart_class, "<init>", "()V");
8101         CHECK(LDKParseError_TooShortDataPart_meth != NULL);
8102         LDKParseError_UnexpectedEndOfTaggedFields_class =
8103                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnexpectedEndOfTaggedFields"));
8104         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_class != NULL);
8105         LDKParseError_UnexpectedEndOfTaggedFields_meth = (*env)->GetMethodID(env, LDKParseError_UnexpectedEndOfTaggedFields_class, "<init>", "()V");
8106         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_meth != NULL);
8107         LDKParseError_DescriptionDecodeError_class =
8108                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$DescriptionDecodeError"));
8109         CHECK(LDKParseError_DescriptionDecodeError_class != NULL);
8110         LDKParseError_DescriptionDecodeError_meth = (*env)->GetMethodID(env, LDKParseError_DescriptionDecodeError_class, "<init>", "(I)V");
8111         CHECK(LDKParseError_DescriptionDecodeError_meth != NULL);
8112         LDKParseError_PaddingError_class =
8113                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$PaddingError"));
8114         CHECK(LDKParseError_PaddingError_class != NULL);
8115         LDKParseError_PaddingError_meth = (*env)->GetMethodID(env, LDKParseError_PaddingError_class, "<init>", "()V");
8116         CHECK(LDKParseError_PaddingError_meth != NULL);
8117         LDKParseError_IntegerOverflowError_class =
8118                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$IntegerOverflowError"));
8119         CHECK(LDKParseError_IntegerOverflowError_class != NULL);
8120         LDKParseError_IntegerOverflowError_meth = (*env)->GetMethodID(env, LDKParseError_IntegerOverflowError_class, "<init>", "()V");
8121         CHECK(LDKParseError_IntegerOverflowError_meth != NULL);
8122         LDKParseError_InvalidSegWitProgramLength_class =
8123                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSegWitProgramLength"));
8124         CHECK(LDKParseError_InvalidSegWitProgramLength_class != NULL);
8125         LDKParseError_InvalidSegWitProgramLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSegWitProgramLength_class, "<init>", "()V");
8126         CHECK(LDKParseError_InvalidSegWitProgramLength_meth != NULL);
8127         LDKParseError_InvalidPubKeyHashLength_class =
8128                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidPubKeyHashLength"));
8129         CHECK(LDKParseError_InvalidPubKeyHashLength_class != NULL);
8130         LDKParseError_InvalidPubKeyHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidPubKeyHashLength_class, "<init>", "()V");
8131         CHECK(LDKParseError_InvalidPubKeyHashLength_meth != NULL);
8132         LDKParseError_InvalidScriptHashLength_class =
8133                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidScriptHashLength"));
8134         CHECK(LDKParseError_InvalidScriptHashLength_class != NULL);
8135         LDKParseError_InvalidScriptHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidScriptHashLength_class, "<init>", "()V");
8136         CHECK(LDKParseError_InvalidScriptHashLength_meth != NULL);
8137         LDKParseError_InvalidRecoveryId_class =
8138                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidRecoveryId"));
8139         CHECK(LDKParseError_InvalidRecoveryId_class != NULL);
8140         LDKParseError_InvalidRecoveryId_meth = (*env)->GetMethodID(env, LDKParseError_InvalidRecoveryId_class, "<init>", "()V");
8141         CHECK(LDKParseError_InvalidRecoveryId_meth != NULL);
8142         LDKParseError_InvalidSliceLength_class =
8143                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSliceLength"));
8144         CHECK(LDKParseError_InvalidSliceLength_class != NULL);
8145         LDKParseError_InvalidSliceLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSliceLength_class, "<init>", "(Ljava/lang/String;)V");
8146         CHECK(LDKParseError_InvalidSliceLength_meth != NULL);
8147         LDKParseError_Skip_class =
8148                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Skip"));
8149         CHECK(LDKParseError_Skip_class != NULL);
8150         LDKParseError_Skip_meth = (*env)->GetMethodID(env, LDKParseError_Skip_class, "<init>", "()V");
8151         CHECK(LDKParseError_Skip_meth != NULL);
8152 }
8153 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8154         LDKParseError *obj = (LDKParseError*)untag_ptr(ptr);
8155         switch(obj->tag) {
8156                 case LDKParseError_Bech32Error: {
8157                         int64_t bech32_error_ref = tag_ptr(&obj->bech32_error, false);
8158                         return (*env)->NewObject(env, LDKParseError_Bech32Error_class, LDKParseError_Bech32Error_meth, bech32_error_ref);
8159                 }
8160                 case LDKParseError_ParseAmountError: {
8161                         /*obj->parse_amount_error*/
8162                         return (*env)->NewObject(env, LDKParseError_ParseAmountError_class, LDKParseError_ParseAmountError_meth, 0);
8163                 }
8164                 case LDKParseError_MalformedSignature: {
8165                         jclass malformed_signature_conv = LDKSecp256k1Error_to_java(env, obj->malformed_signature);
8166                         return (*env)->NewObject(env, LDKParseError_MalformedSignature_class, LDKParseError_MalformedSignature_meth, malformed_signature_conv);
8167                 }
8168                 case LDKParseError_BadPrefix: {
8169                         return (*env)->NewObject(env, LDKParseError_BadPrefix_class, LDKParseError_BadPrefix_meth);
8170                 }
8171                 case LDKParseError_UnknownCurrency: {
8172                         return (*env)->NewObject(env, LDKParseError_UnknownCurrency_class, LDKParseError_UnknownCurrency_meth);
8173                 }
8174                 case LDKParseError_UnknownSiPrefix: {
8175                         return (*env)->NewObject(env, LDKParseError_UnknownSiPrefix_class, LDKParseError_UnknownSiPrefix_meth);
8176                 }
8177                 case LDKParseError_MalformedHRP: {
8178                         return (*env)->NewObject(env, LDKParseError_MalformedHRP_class, LDKParseError_MalformedHRP_meth);
8179                 }
8180                 case LDKParseError_TooShortDataPart: {
8181                         return (*env)->NewObject(env, LDKParseError_TooShortDataPart_class, LDKParseError_TooShortDataPart_meth);
8182                 }
8183                 case LDKParseError_UnexpectedEndOfTaggedFields: {
8184                         return (*env)->NewObject(env, LDKParseError_UnexpectedEndOfTaggedFields_class, LDKParseError_UnexpectedEndOfTaggedFields_meth);
8185                 }
8186                 case LDKParseError_DescriptionDecodeError: {
8187                         /*obj->description_decode_error*/
8188                         return (*env)->NewObject(env, LDKParseError_DescriptionDecodeError_class, LDKParseError_DescriptionDecodeError_meth, 0);
8189                 }
8190                 case LDKParseError_PaddingError: {
8191                         return (*env)->NewObject(env, LDKParseError_PaddingError_class, LDKParseError_PaddingError_meth);
8192                 }
8193                 case LDKParseError_IntegerOverflowError: {
8194                         return (*env)->NewObject(env, LDKParseError_IntegerOverflowError_class, LDKParseError_IntegerOverflowError_meth);
8195                 }
8196                 case LDKParseError_InvalidSegWitProgramLength: {
8197                         return (*env)->NewObject(env, LDKParseError_InvalidSegWitProgramLength_class, LDKParseError_InvalidSegWitProgramLength_meth);
8198                 }
8199                 case LDKParseError_InvalidPubKeyHashLength: {
8200                         return (*env)->NewObject(env, LDKParseError_InvalidPubKeyHashLength_class, LDKParseError_InvalidPubKeyHashLength_meth);
8201                 }
8202                 case LDKParseError_InvalidScriptHashLength: {
8203                         return (*env)->NewObject(env, LDKParseError_InvalidScriptHashLength_class, LDKParseError_InvalidScriptHashLength_meth);
8204                 }
8205                 case LDKParseError_InvalidRecoveryId: {
8206                         return (*env)->NewObject(env, LDKParseError_InvalidRecoveryId_class, LDKParseError_InvalidRecoveryId_meth);
8207                 }
8208                 case LDKParseError_InvalidSliceLength: {
8209                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
8210                         jstring invalid_slice_length_conv = str_ref_to_java(env, invalid_slice_length_str.chars, invalid_slice_length_str.len);
8211                         return (*env)->NewObject(env, LDKParseError_InvalidSliceLength_class, LDKParseError_InvalidSliceLength_meth, invalid_slice_length_conv);
8212                 }
8213                 case LDKParseError_Skip: {
8214                         return (*env)->NewObject(env, LDKParseError_Skip_class, LDKParseError_Skip_meth);
8215                 }
8216                 default: abort();
8217         }
8218 }
8219 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
8220 CHECK(owner->result_ok);
8221         return SiPrefix_clone(&*owner->contents.result);
8222 }
8223 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8224         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(owner);
8225         jclass ret_conv = LDKSiPrefix_to_java(env, CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
8226         return ret_conv;
8227 }
8228
8229 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
8230 CHECK(!owner->result_ok);
8231         return ParseError_clone(&*owner->contents.err);
8232 }
8233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8234         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(owner);
8235         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
8236         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
8237         int64_t ret_ref = tag_ptr(ret_copy, true);
8238         return ret_ref;
8239 }
8240
8241 static jclass LDKParseOrSemanticError_ParseError_class = NULL;
8242 static jmethodID LDKParseOrSemanticError_ParseError_meth = NULL;
8243 static jclass LDKParseOrSemanticError_SemanticError_class = NULL;
8244 static jmethodID LDKParseOrSemanticError_SemanticError_meth = NULL;
8245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseOrSemanticError_init (JNIEnv *env, jclass clz) {
8246         LDKParseOrSemanticError_ParseError_class =
8247                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$ParseError"));
8248         CHECK(LDKParseOrSemanticError_ParseError_class != NULL);
8249         LDKParseOrSemanticError_ParseError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_ParseError_class, "<init>", "(J)V");
8250         CHECK(LDKParseOrSemanticError_ParseError_meth != NULL);
8251         LDKParseOrSemanticError_SemanticError_class =
8252                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$SemanticError"));
8253         CHECK(LDKParseOrSemanticError_SemanticError_class != NULL);
8254         LDKParseOrSemanticError_SemanticError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_SemanticError_class, "<init>", "(Lorg/ldk/enums/SemanticError;)V");
8255         CHECK(LDKParseOrSemanticError_SemanticError_meth != NULL);
8256 }
8257 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseOrSemanticError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8258         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)untag_ptr(ptr);
8259         switch(obj->tag) {
8260                 case LDKParseOrSemanticError_ParseError: {
8261                         int64_t parse_error_ref = tag_ptr(&obj->parse_error, false);
8262                         return (*env)->NewObject(env, LDKParseOrSemanticError_ParseError_class, LDKParseOrSemanticError_ParseError_meth, parse_error_ref);
8263                 }
8264                 case LDKParseOrSemanticError_SemanticError: {
8265                         jclass semantic_error_conv = LDKSemanticError_to_java(env, obj->semantic_error);
8266                         return (*env)->NewObject(env, LDKParseOrSemanticError_SemanticError_class, LDKParseOrSemanticError_SemanticError_meth, semantic_error_conv);
8267                 }
8268                 default: abort();
8269         }
8270 }
8271 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
8272         LDKInvoice ret = *owner->contents.result;
8273         ret.is_owned = false;
8274         return ret;
8275 }
8276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8277         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
8278         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
8279         int64_t ret_ref = 0;
8280         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8281         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8282         return ret_ref;
8283 }
8284
8285 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
8286 CHECK(!owner->result_ok);
8287         return ParseOrSemanticError_clone(&*owner->contents.err);
8288 }
8289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8290         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
8291         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
8292         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
8293         int64_t ret_ref = tag_ptr(ret_copy, true);
8294         return ret_ref;
8295 }
8296
8297 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
8298         LDKSignedRawInvoice ret = *owner->contents.result;
8299         ret.is_owned = false;
8300         return ret;
8301 }
8302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8303         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(owner);
8304         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
8305         int64_t ret_ref = 0;
8306         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8307         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8308         return ret_ref;
8309 }
8310
8311 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
8312 CHECK(!owner->result_ok);
8313         return ParseError_clone(&*owner->contents.err);
8314 }
8315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8316         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(owner);
8317         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
8318         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
8319         int64_t ret_ref = tag_ptr(ret_copy, true);
8320         return ret_ref;
8321 }
8322
8323 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
8324         LDKRawInvoice ret = owner->a;
8325         ret.is_owned = false;
8326         return ret;
8327 }
8328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8329         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
8330         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
8331         int64_t ret_ref = 0;
8332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8333         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8334         return ret_ref;
8335 }
8336
8337 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
8338         return ThirtyTwoBytes_clone(&owner->b);
8339 }
8340 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8341         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
8342         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8343         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data);
8344         return ret_arr;
8345 }
8346
8347 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
8348         LDKInvoiceSignature ret = owner->c;
8349         ret.is_owned = false;
8350         return ret;
8351 }
8352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
8353         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
8354         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
8355         int64_t ret_ref = 0;
8356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8357         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8358         return ret_ref;
8359 }
8360
8361 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
8362         LDKPayeePubKey ret = *owner->contents.result;
8363         ret.is_owned = false;
8364         return ret;
8365 }
8366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8367         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(owner);
8368         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
8369         int64_t ret_ref = 0;
8370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8371         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8372         return ret_ref;
8373 }
8374
8375 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
8376 CHECK(!owner->result_ok);
8377         return *owner->contents.err;
8378 }
8379 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8380         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(owner);
8381         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PayeePubKeyErrorZ_get_err(owner_conv));
8382         return ret_conv;
8383 }
8384
8385 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
8386         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
8387         for (size_t i = 0; i < ret.datalen; i++) {
8388                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
8389         }
8390         return ret;
8391 }
8392 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
8393         LDKPositiveTimestamp ret = *owner->contents.result;
8394         ret.is_owned = false;
8395         return ret;
8396 }
8397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8398         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
8399         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
8400         int64_t ret_ref = 0;
8401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8402         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8403         return ret_ref;
8404 }
8405
8406 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
8407 CHECK(!owner->result_ok);
8408         return CreationError_clone(&*owner->contents.err);
8409 }
8410 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8411         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
8412         jclass ret_conv = LDKCreationError_to_java(env, CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
8413         return ret_conv;
8414 }
8415
8416 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
8417 CHECK(owner->result_ok);
8418         return *owner->contents.result;
8419 }
8420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8421         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(owner);
8422         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
8423 }
8424
8425 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
8426 CHECK(!owner->result_ok);
8427         return SemanticError_clone(&*owner->contents.err);
8428 }
8429 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8430         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(owner);
8431         jclass ret_conv = LDKSemanticError_to_java(env, CResult_NoneSemanticErrorZ_get_err(owner_conv));
8432         return ret_conv;
8433 }
8434
8435 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
8436         LDKInvoice ret = *owner->contents.result;
8437         ret.is_owned = false;
8438         return ret;
8439 }
8440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8441         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(owner);
8442         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
8443         int64_t ret_ref = 0;
8444         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8445         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8446         return ret_ref;
8447 }
8448
8449 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
8450 CHECK(!owner->result_ok);
8451         return SemanticError_clone(&*owner->contents.err);
8452 }
8453 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8454         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(owner);
8455         jclass ret_conv = LDKSemanticError_to_java(env, CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
8456         return ret_conv;
8457 }
8458
8459 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
8460         LDKDescription ret = *owner->contents.result;
8461         ret.is_owned = false;
8462         return ret;
8463 }
8464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8465         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
8466         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
8467         int64_t ret_ref = 0;
8468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8469         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8470         return ret_ref;
8471 }
8472
8473 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
8474 CHECK(!owner->result_ok);
8475         return CreationError_clone(&*owner->contents.err);
8476 }
8477 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8478         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
8479         jclass ret_conv = LDKCreationError_to_java(env, CResult_DescriptionCreationErrorZ_get_err(owner_conv));
8480         return ret_conv;
8481 }
8482
8483 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
8484         LDKPrivateRoute ret = *owner->contents.result;
8485         ret.is_owned = false;
8486         return ret;
8487 }
8488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8489         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
8490         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
8491         int64_t ret_ref = 0;
8492         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8493         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8494         return ret_ref;
8495 }
8496
8497 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
8498 CHECK(!owner->result_ok);
8499         return CreationError_clone(&*owner->contents.err);
8500 }
8501 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8502         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
8503         jclass ret_conv = LDKCreationError_to_java(env, CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
8504         return ret_conv;
8505 }
8506
8507 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
8508 CHECK(owner->result_ok);
8509         return *owner->contents.result;
8510 }
8511 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8512         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)untag_ptr(owner);
8513         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
8514         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8515         return ret_conv;
8516 }
8517
8518 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
8519 CHECK(!owner->result_ok);
8520         return *owner->contents.err;
8521 }
8522 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8523         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)untag_ptr(owner);
8524         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_StringErrorZ_get_err(owner_conv));
8525         return ret_conv;
8526 }
8527
8528 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
8529         LDKChannelMonitorUpdate ret = *owner->contents.result;
8530         ret.is_owned = false;
8531         return ret;
8532 }
8533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8534         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
8535         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
8536         int64_t ret_ref = 0;
8537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8538         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8539         return ret_ref;
8540 }
8541
8542 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
8543         LDKDecodeError ret = *owner->contents.err;
8544         ret.is_owned = false;
8545         return ret;
8546 }
8547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8548         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
8549         LDKDecodeError ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
8550         int64_t ret_ref = 0;
8551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8552         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8553         return ret_ref;
8554 }
8555
8556 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
8557 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
8558 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
8559 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
8560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
8561         LDKCOption_MonitorEventZ_Some_class =
8562                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
8563         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
8564         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
8565         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
8566         LDKCOption_MonitorEventZ_None_class =
8567                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
8568         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
8569         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
8570         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
8571 }
8572 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8573         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)untag_ptr(ptr);
8574         switch(obj->tag) {
8575                 case LDKCOption_MonitorEventZ_Some: {
8576                         int64_t some_ref = tag_ptr(&obj->some, false);
8577                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
8578                 }
8579                 case LDKCOption_MonitorEventZ_None: {
8580                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
8581                 }
8582                 default: abort();
8583         }
8584 }
8585 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
8586 CHECK(owner->result_ok);
8587         return COption_MonitorEventZ_clone(&*owner->contents.result);
8588 }
8589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8590         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
8591         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
8592         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
8593         int64_t ret_ref = tag_ptr(ret_copy, true);
8594         return ret_ref;
8595 }
8596
8597 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
8598         LDKDecodeError ret = *owner->contents.err;
8599         ret.is_owned = false;
8600         return ret;
8601 }
8602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8603         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
8604         LDKDecodeError ret_var = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
8605         int64_t ret_ref = 0;
8606         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8607         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8608         return ret_ref;
8609 }
8610
8611 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
8612         LDKHTLCUpdate ret = *owner->contents.result;
8613         ret.is_owned = false;
8614         return ret;
8615 }
8616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8617         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
8618         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
8619         int64_t ret_ref = 0;
8620         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8621         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8622         return ret_ref;
8623 }
8624
8625 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
8626         LDKDecodeError ret = *owner->contents.err;
8627         ret.is_owned = false;
8628         return ret;
8629 }
8630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8631         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
8632         LDKDecodeError ret_var = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
8633         int64_t ret_ref = 0;
8634         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8635         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8636         return ret_ref;
8637 }
8638
8639 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
8640         LDKOutPoint ret = owner->a;
8641         ret.is_owned = false;
8642         return ret;
8643 }
8644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8645         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(owner);
8646         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
8647         int64_t ret_ref = 0;
8648         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8649         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8650         return ret_ref;
8651 }
8652
8653 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
8654         return CVec_u8Z_clone(&owner->b);
8655 }
8656 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8657         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(owner);
8658         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
8659         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8660         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8661         CVec_u8Z_free(ret_var);
8662         return ret_arr;
8663 }
8664
8665 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
8666         return owner->a;
8667 }
8668 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8669         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(owner);
8670         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
8671         return ret_conv;
8672 }
8673
8674 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
8675         return CVec_u8Z_clone(&owner->b);
8676 }
8677 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8678         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(owner);
8679         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
8680         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8681         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8682         CVec_u8Z_free(ret_var);
8683         return ret_arr;
8684 }
8685
8686 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
8687         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
8688         for (size_t i = 0; i < ret.datalen; i++) {
8689                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
8690         }
8691         return ret;
8692 }
8693 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
8694         return ThirtyTwoBytes_clone(&owner->a);
8695 }
8696 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8697         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(owner);
8698         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8699         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data);
8700         return ret_arr;
8701 }
8702
8703 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
8704         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
8705 }
8706 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8707         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(owner);
8708         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
8709         int64_tArray ret_arr = NULL;
8710         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8711         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8712         for (size_t v = 0; v < ret_var.datalen; v++) {
8713                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
8714                 *ret_conv_21_conv = ret_var.data[v];
8715                 ret_arr_ptr[v] = tag_ptr(ret_conv_21_conv, true);
8716         }
8717         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8718         FREE(ret_var.data);
8719         return ret_arr;
8720 }
8721
8722 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
8723         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 };
8724         for (size_t i = 0; i < ret.datalen; i++) {
8725                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
8726         }
8727         return ret;
8728 }
8729 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
8730         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
8731         for (size_t i = 0; i < ret.datalen; i++) {
8732                 ret.data[i] = Event_clone(&orig->data[i]);
8733         }
8734         return ret;
8735 }
8736 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
8737         return owner->a;
8738 }
8739 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8740         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
8741         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
8742         return ret_conv;
8743 }
8744
8745 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
8746         return TxOut_clone(&owner->b);
8747 }
8748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8749         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
8750         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8751         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
8752         return tag_ptr(ret_ref, true);
8753 }
8754
8755 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
8756         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
8757         for (size_t i = 0; i < ret.datalen; i++) {
8758                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
8759         }
8760         return ret;
8761 }
8762 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
8763         return ThirtyTwoBytes_clone(&owner->a);
8764 }
8765 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8766         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
8767         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8768         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data);
8769         return ret_arr;
8770 }
8771
8772 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
8773         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
8774 }
8775 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8776         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
8777         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
8778         int64_tArray ret_arr = NULL;
8779         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8780         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8781         for (size_t u = 0; u < ret_var.datalen; u++) {
8782                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
8783                 *ret_conv_20_conv = ret_var.data[u];
8784                 ret_arr_ptr[u] = tag_ptr(ret_conv_20_conv, true);
8785         }
8786         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8787         FREE(ret_var.data);
8788         return ret_arr;
8789 }
8790
8791 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
8792         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 };
8793         for (size_t i = 0; i < ret.datalen; i++) {
8794                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
8795         }
8796         return ret;
8797 }
8798 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
8799 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
8800 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
8801 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
8802 static jclass LDKBalance_ContentiousClaimable_class = NULL;
8803 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
8804 static jclass LDKBalance_MaybeTimeoutClaimableHTLC_class = NULL;
8805 static jmethodID LDKBalance_MaybeTimeoutClaimableHTLC_meth = NULL;
8806 static jclass LDKBalance_MaybePreimageClaimableHTLC_class = NULL;
8807 static jmethodID LDKBalance_MaybePreimageClaimableHTLC_meth = NULL;
8808 static jclass LDKBalance_CounterpartyRevokedOutputClaimable_class = NULL;
8809 static jmethodID LDKBalance_CounterpartyRevokedOutputClaimable_meth = NULL;
8810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
8811         LDKBalance_ClaimableOnChannelClose_class =
8812                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
8813         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
8814         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
8815         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
8816         LDKBalance_ClaimableAwaitingConfirmations_class =
8817                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
8818         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
8819         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
8820         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
8821         LDKBalance_ContentiousClaimable_class =
8822                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
8823         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
8824         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
8825         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
8826         LDKBalance_MaybeTimeoutClaimableHTLC_class =
8827                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeTimeoutClaimableHTLC"));
8828         CHECK(LDKBalance_MaybeTimeoutClaimableHTLC_class != NULL);
8829         LDKBalance_MaybeTimeoutClaimableHTLC_meth = (*env)->GetMethodID(env, LDKBalance_MaybeTimeoutClaimableHTLC_class, "<init>", "(JI)V");
8830         CHECK(LDKBalance_MaybeTimeoutClaimableHTLC_meth != NULL);
8831         LDKBalance_MaybePreimageClaimableHTLC_class =
8832                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybePreimageClaimableHTLC"));
8833         CHECK(LDKBalance_MaybePreimageClaimableHTLC_class != NULL);
8834         LDKBalance_MaybePreimageClaimableHTLC_meth = (*env)->GetMethodID(env, LDKBalance_MaybePreimageClaimableHTLC_class, "<init>", "(JI)V");
8835         CHECK(LDKBalance_MaybePreimageClaimableHTLC_meth != NULL);
8836         LDKBalance_CounterpartyRevokedOutputClaimable_class =
8837                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$CounterpartyRevokedOutputClaimable"));
8838         CHECK(LDKBalance_CounterpartyRevokedOutputClaimable_class != NULL);
8839         LDKBalance_CounterpartyRevokedOutputClaimable_meth = (*env)->GetMethodID(env, LDKBalance_CounterpartyRevokedOutputClaimable_class, "<init>", "(J)V");
8840         CHECK(LDKBalance_CounterpartyRevokedOutputClaimable_meth != NULL);
8841 }
8842 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8843         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
8844         switch(obj->tag) {
8845                 case LDKBalance_ClaimableOnChannelClose: {
8846                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
8847                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, claimable_amount_satoshis_conv);
8848                 }
8849                 case LDKBalance_ClaimableAwaitingConfirmations: {
8850                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
8851                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
8852                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, claimable_amount_satoshis_conv, confirmation_height_conv);
8853                 }
8854                 case LDKBalance_ContentiousClaimable: {
8855                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
8856                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
8857                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, claimable_amount_satoshis_conv, timeout_height_conv);
8858                 }
8859                 case LDKBalance_MaybeTimeoutClaimableHTLC: {
8860                         int64_t claimable_amount_satoshis_conv = obj->maybe_timeout_claimable_htlc.claimable_amount_satoshis;
8861                         int32_t claimable_height_conv = obj->maybe_timeout_claimable_htlc.claimable_height;
8862                         return (*env)->NewObject(env, LDKBalance_MaybeTimeoutClaimableHTLC_class, LDKBalance_MaybeTimeoutClaimableHTLC_meth, claimable_amount_satoshis_conv, claimable_height_conv);
8863                 }
8864                 case LDKBalance_MaybePreimageClaimableHTLC: {
8865                         int64_t claimable_amount_satoshis_conv = obj->maybe_preimage_claimable_htlc.claimable_amount_satoshis;
8866                         int32_t expiry_height_conv = obj->maybe_preimage_claimable_htlc.expiry_height;
8867                         return (*env)->NewObject(env, LDKBalance_MaybePreimageClaimableHTLC_class, LDKBalance_MaybePreimageClaimableHTLC_meth, claimable_amount_satoshis_conv, expiry_height_conv);
8868                 }
8869                 case LDKBalance_CounterpartyRevokedOutputClaimable: {
8870                         int64_t claimable_amount_satoshis_conv = obj->counterparty_revoked_output_claimable.claimable_amount_satoshis;
8871                         return (*env)->NewObject(env, LDKBalance_CounterpartyRevokedOutputClaimable_class, LDKBalance_CounterpartyRevokedOutputClaimable_meth, claimable_amount_satoshis_conv);
8872                 }
8873                 default: abort();
8874         }
8875 }
8876 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
8877         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
8878         for (size_t i = 0; i < ret.datalen; i++) {
8879                 ret.data[i] = Balance_clone(&orig->data[i]);
8880         }
8881         return ret;
8882 }
8883 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
8884 CHECK(owner->result_ok);
8885         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
8886 }
8887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8888         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
8889         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
8890         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
8891         return tag_ptr(ret_conv, true);
8892 }
8893
8894 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
8895         LDKDecodeError ret = *owner->contents.err;
8896         ret.is_owned = false;
8897         return ret;
8898 }
8899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8900         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
8901         LDKDecodeError ret_var = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
8902         int64_t ret_ref = 0;
8903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8904         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8905         return ret_ref;
8906 }
8907
8908 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
8909         return owner->a;
8910 }
8911 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8912         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
8913         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
8914         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form);
8915         return ret_arr;
8916 }
8917
8918 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
8919         return Type_clone(&owner->b);
8920 }
8921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8922         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
8923         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
8924         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
8925         return tag_ptr(ret_ret, true);
8926 }
8927
8928 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
8929         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
8930         for (size_t i = 0; i < ret.datalen; i++) {
8931                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
8932         }
8933         return ret;
8934 }
8935 static jclass LDKCOption_NetAddressZ_Some_class = NULL;
8936 static jmethodID LDKCOption_NetAddressZ_Some_meth = NULL;
8937 static jclass LDKCOption_NetAddressZ_None_class = NULL;
8938 static jmethodID LDKCOption_NetAddressZ_None_meth = NULL;
8939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetAddressZ_init (JNIEnv *env, jclass clz) {
8940         LDKCOption_NetAddressZ_Some_class =
8941                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$Some"));
8942         CHECK(LDKCOption_NetAddressZ_Some_class != NULL);
8943         LDKCOption_NetAddressZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_Some_class, "<init>", "(J)V");
8944         CHECK(LDKCOption_NetAddressZ_Some_meth != NULL);
8945         LDKCOption_NetAddressZ_None_class =
8946                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$None"));
8947         CHECK(LDKCOption_NetAddressZ_None_class != NULL);
8948         LDKCOption_NetAddressZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_None_class, "<init>", "()V");
8949         CHECK(LDKCOption_NetAddressZ_None_meth != NULL);
8950 }
8951 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetAddressZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8952         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)untag_ptr(ptr);
8953         switch(obj->tag) {
8954                 case LDKCOption_NetAddressZ_Some: {
8955                         int64_t some_ref = tag_ptr(&obj->some, false);
8956                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_Some_class, LDKCOption_NetAddressZ_Some_meth, some_ref);
8957                 }
8958                 case LDKCOption_NetAddressZ_None: {
8959                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_None_class, LDKCOption_NetAddressZ_None_meth);
8960                 }
8961                 default: abort();
8962         }
8963 }
8964 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
8965 CHECK(owner->result_ok);
8966         return CVec_u8Z_clone(&*owner->contents.result);
8967 }
8968 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8969         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
8970         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
8971         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8972         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8973         CVec_u8Z_free(ret_var);
8974         return ret_arr;
8975 }
8976
8977 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
8978         LDKPeerHandleError ret = *owner->contents.err;
8979         ret.is_owned = false;
8980         return ret;
8981 }
8982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8983         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
8984         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
8985         int64_t ret_ref = 0;
8986         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8987         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8988         return ret_ref;
8989 }
8990
8991 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
8992 CHECK(owner->result_ok);
8993         return *owner->contents.result;
8994 }
8995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8996         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
8997         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
8998 }
8999
9000 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
9001         LDKPeerHandleError ret = *owner->contents.err;
9002         ret.is_owned = false;
9003         return ret;
9004 }
9005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9006         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
9007         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
9008         int64_t ret_ref = 0;
9009         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9010         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9011         return ret_ref;
9012 }
9013
9014 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
9015 CHECK(owner->result_ok);
9016         return *owner->contents.result;
9017 }
9018 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9019         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
9020         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
9021         return ret_conv;
9022 }
9023
9024 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
9025         LDKPeerHandleError ret = *owner->contents.err;
9026         ret.is_owned = false;
9027         return ret;
9028 }
9029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9030         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
9031         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
9032         int64_t ret_ref = 0;
9033         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9034         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9035         return ret_ref;
9036 }
9037
9038 static jclass LDKSendError_Secp256k1_class = NULL;
9039 static jmethodID LDKSendError_Secp256k1_meth = NULL;
9040 static jclass LDKSendError_TooBigPacket_class = NULL;
9041 static jmethodID LDKSendError_TooBigPacket_meth = NULL;
9042 static jclass LDKSendError_TooFewBlindedHops_class = NULL;
9043 static jmethodID LDKSendError_TooFewBlindedHops_meth = NULL;
9044 static jclass LDKSendError_InvalidFirstHop_class = NULL;
9045 static jmethodID LDKSendError_InvalidFirstHop_meth = NULL;
9046 static jclass LDKSendError_BufferFull_class = NULL;
9047 static jmethodID LDKSendError_BufferFull_meth = NULL;
9048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSendError_init (JNIEnv *env, jclass clz) {
9049         LDKSendError_Secp256k1_class =
9050                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$Secp256k1"));
9051         CHECK(LDKSendError_Secp256k1_class != NULL);
9052         LDKSendError_Secp256k1_meth = (*env)->GetMethodID(env, LDKSendError_Secp256k1_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
9053         CHECK(LDKSendError_Secp256k1_meth != NULL);
9054         LDKSendError_TooBigPacket_class =
9055                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$TooBigPacket"));
9056         CHECK(LDKSendError_TooBigPacket_class != NULL);
9057         LDKSendError_TooBigPacket_meth = (*env)->GetMethodID(env, LDKSendError_TooBigPacket_class, "<init>", "()V");
9058         CHECK(LDKSendError_TooBigPacket_meth != NULL);
9059         LDKSendError_TooFewBlindedHops_class =
9060                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$TooFewBlindedHops"));
9061         CHECK(LDKSendError_TooFewBlindedHops_class != NULL);
9062         LDKSendError_TooFewBlindedHops_meth = (*env)->GetMethodID(env, LDKSendError_TooFewBlindedHops_class, "<init>", "()V");
9063         CHECK(LDKSendError_TooFewBlindedHops_meth != NULL);
9064         LDKSendError_InvalidFirstHop_class =
9065                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$InvalidFirstHop"));
9066         CHECK(LDKSendError_InvalidFirstHop_class != NULL);
9067         LDKSendError_InvalidFirstHop_meth = (*env)->GetMethodID(env, LDKSendError_InvalidFirstHop_class, "<init>", "()V");
9068         CHECK(LDKSendError_InvalidFirstHop_meth != NULL);
9069         LDKSendError_BufferFull_class =
9070                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$BufferFull"));
9071         CHECK(LDKSendError_BufferFull_class != NULL);
9072         LDKSendError_BufferFull_meth = (*env)->GetMethodID(env, LDKSendError_BufferFull_class, "<init>", "()V");
9073         CHECK(LDKSendError_BufferFull_meth != NULL);
9074 }
9075 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSendError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9076         LDKSendError *obj = (LDKSendError*)untag_ptr(ptr);
9077         switch(obj->tag) {
9078                 case LDKSendError_Secp256k1: {
9079                         jclass secp256k1_conv = LDKSecp256k1Error_to_java(env, obj->secp256k1);
9080                         return (*env)->NewObject(env, LDKSendError_Secp256k1_class, LDKSendError_Secp256k1_meth, secp256k1_conv);
9081                 }
9082                 case LDKSendError_TooBigPacket: {
9083                         return (*env)->NewObject(env, LDKSendError_TooBigPacket_class, LDKSendError_TooBigPacket_meth);
9084                 }
9085                 case LDKSendError_TooFewBlindedHops: {
9086                         return (*env)->NewObject(env, LDKSendError_TooFewBlindedHops_class, LDKSendError_TooFewBlindedHops_meth);
9087                 }
9088                 case LDKSendError_InvalidFirstHop: {
9089                         return (*env)->NewObject(env, LDKSendError_InvalidFirstHop_class, LDKSendError_InvalidFirstHop_meth);
9090                 }
9091                 case LDKSendError_BufferFull: {
9092                         return (*env)->NewObject(env, LDKSendError_BufferFull_class, LDKSendError_BufferFull_meth);
9093                 }
9094                 default: abort();
9095         }
9096 }
9097 static inline void CResult_NoneSendErrorZ_get_ok(LDKCResult_NoneSendErrorZ *NONNULL_PTR owner){
9098 CHECK(owner->result_ok);
9099         return *owner->contents.result;
9100 }
9101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9102         LDKCResult_NoneSendErrorZ* owner_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(owner);
9103         CResult_NoneSendErrorZ_get_ok(owner_conv);
9104 }
9105
9106 static inline struct LDKSendError CResult_NoneSendErrorZ_get_err(LDKCResult_NoneSendErrorZ *NONNULL_PTR owner){
9107 CHECK(!owner->result_ok);
9108         return SendError_clone(&*owner->contents.err);
9109 }
9110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9111         LDKCResult_NoneSendErrorZ* owner_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(owner);
9112         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
9113         *ret_copy = CResult_NoneSendErrorZ_get_err(owner_conv);
9114         int64_t ret_ref = tag_ptr(ret_copy, true);
9115         return ret_ref;
9116 }
9117
9118 static jclass LDKGraphSyncError_DecodeError_class = NULL;
9119 static jmethodID LDKGraphSyncError_DecodeError_meth = NULL;
9120 static jclass LDKGraphSyncError_LightningError_class = NULL;
9121 static jmethodID LDKGraphSyncError_LightningError_meth = NULL;
9122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGraphSyncError_init (JNIEnv *env, jclass clz) {
9123         LDKGraphSyncError_DecodeError_class =
9124                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$DecodeError"));
9125         CHECK(LDKGraphSyncError_DecodeError_class != NULL);
9126         LDKGraphSyncError_DecodeError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_DecodeError_class, "<init>", "(J)V");
9127         CHECK(LDKGraphSyncError_DecodeError_meth != NULL);
9128         LDKGraphSyncError_LightningError_class =
9129                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$LightningError"));
9130         CHECK(LDKGraphSyncError_LightningError_class != NULL);
9131         LDKGraphSyncError_LightningError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_LightningError_class, "<init>", "(J)V");
9132         CHECK(LDKGraphSyncError_LightningError_meth != NULL);
9133 }
9134 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGraphSyncError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9135         LDKGraphSyncError *obj = (LDKGraphSyncError*)untag_ptr(ptr);
9136         switch(obj->tag) {
9137                 case LDKGraphSyncError_DecodeError: {
9138                         LDKDecodeError decode_error_var = obj->decode_error;
9139                         int64_t decode_error_ref = 0;
9140                         CHECK_INNER_FIELD_ACCESS_OR_NULL(decode_error_var);
9141                         decode_error_ref = tag_ptr(decode_error_var.inner, false);
9142                         return (*env)->NewObject(env, LDKGraphSyncError_DecodeError_class, LDKGraphSyncError_DecodeError_meth, decode_error_ref);
9143                 }
9144                 case LDKGraphSyncError_LightningError: {
9145                         LDKLightningError lightning_error_var = obj->lightning_error;
9146                         int64_t lightning_error_ref = 0;
9147                         CHECK_INNER_FIELD_ACCESS_OR_NULL(lightning_error_var);
9148                         lightning_error_ref = tag_ptr(lightning_error_var.inner, false);
9149                         return (*env)->NewObject(env, LDKGraphSyncError_LightningError_class, LDKGraphSyncError_LightningError_meth, lightning_error_ref);
9150                 }
9151                 default: abort();
9152         }
9153 }
9154 static inline uint32_t CResult_u32GraphSyncErrorZ_get_ok(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
9155 CHECK(owner->result_ok);
9156         return *owner->contents.result;
9157 }
9158 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9159         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(owner);
9160         int32_t ret_conv = CResult_u32GraphSyncErrorZ_get_ok(owner_conv);
9161         return ret_conv;
9162 }
9163
9164 static inline struct LDKGraphSyncError CResult_u32GraphSyncErrorZ_get_err(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
9165 CHECK(!owner->result_ok);
9166         return GraphSyncError_clone(&*owner->contents.err);
9167 }
9168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9169         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(owner);
9170         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
9171         *ret_copy = CResult_u32GraphSyncErrorZ_get_err(owner_conv);
9172         int64_t ret_ref = tag_ptr(ret_copy, true);
9173         return ret_ref;
9174 }
9175
9176 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
9177 CHECK(owner->result_ok);
9178         return NetAddress_clone(&*owner->contents.result);
9179 }
9180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9181         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(owner);
9182         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
9183         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
9184         int64_t ret_ref = tag_ptr(ret_copy, true);
9185         return ret_ref;
9186 }
9187
9188 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
9189         LDKDecodeError ret = *owner->contents.err;
9190         ret.is_owned = false;
9191         return ret;
9192 }
9193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9194         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(owner);
9195         LDKDecodeError ret_var = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
9196         int64_t ret_ref = 0;
9197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9198         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9199         return ret_ref;
9200 }
9201
9202 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
9203         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
9204         for (size_t i = 0; i < ret.datalen; i++) {
9205                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
9206         }
9207         return ret;
9208 }
9209 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
9210         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
9211         for (size_t i = 0; i < ret.datalen; i++) {
9212                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
9213         }
9214         return ret;
9215 }
9216 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
9217         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
9218         for (size_t i = 0; i < ret.datalen; i++) {
9219                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
9220         }
9221         return ret;
9222 }
9223 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
9224         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
9225         for (size_t i = 0; i < ret.datalen; i++) {
9226                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
9227         }
9228         return ret;
9229 }
9230 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
9231         LDKAcceptChannel ret = *owner->contents.result;
9232         ret.is_owned = false;
9233         return ret;
9234 }
9235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9236         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
9237         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
9238         int64_t ret_ref = 0;
9239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9240         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9241         return ret_ref;
9242 }
9243
9244 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
9245         LDKDecodeError ret = *owner->contents.err;
9246         ret.is_owned = false;
9247         return ret;
9248 }
9249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9250         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
9251         LDKDecodeError ret_var = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
9252         int64_t ret_ref = 0;
9253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9254         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9255         return ret_ref;
9256 }
9257
9258 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
9259         LDKAnnouncementSignatures ret = *owner->contents.result;
9260         ret.is_owned = false;
9261         return ret;
9262 }
9263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9264         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
9265         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
9266         int64_t ret_ref = 0;
9267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9268         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9269         return ret_ref;
9270 }
9271
9272 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
9273         LDKDecodeError ret = *owner->contents.err;
9274         ret.is_owned = false;
9275         return ret;
9276 }
9277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9278         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
9279         LDKDecodeError ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
9280         int64_t ret_ref = 0;
9281         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9282         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9283         return ret_ref;
9284 }
9285
9286 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
9287         LDKChannelReestablish ret = *owner->contents.result;
9288         ret.is_owned = false;
9289         return ret;
9290 }
9291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9292         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
9293         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
9294         int64_t ret_ref = 0;
9295         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9296         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9297         return ret_ref;
9298 }
9299
9300 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
9301         LDKDecodeError ret = *owner->contents.err;
9302         ret.is_owned = false;
9303         return ret;
9304 }
9305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9306         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
9307         LDKDecodeError ret_var = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
9308         int64_t ret_ref = 0;
9309         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9310         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9311         return ret_ref;
9312 }
9313
9314 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
9315         LDKClosingSigned ret = *owner->contents.result;
9316         ret.is_owned = false;
9317         return ret;
9318 }
9319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9320         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
9321         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
9322         int64_t ret_ref = 0;
9323         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9324         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9325         return ret_ref;
9326 }
9327
9328 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
9329         LDKDecodeError ret = *owner->contents.err;
9330         ret.is_owned = false;
9331         return ret;
9332 }
9333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9334         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
9335         LDKDecodeError ret_var = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
9336         int64_t ret_ref = 0;
9337         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9338         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9339         return ret_ref;
9340 }
9341
9342 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
9343         LDKClosingSignedFeeRange ret = *owner->contents.result;
9344         ret.is_owned = false;
9345         return ret;
9346 }
9347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9348         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
9349         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
9350         int64_t ret_ref = 0;
9351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9352         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9353         return ret_ref;
9354 }
9355
9356 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
9357         LDKDecodeError ret = *owner->contents.err;
9358         ret.is_owned = false;
9359         return ret;
9360 }
9361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9362         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
9363         LDKDecodeError ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
9364         int64_t ret_ref = 0;
9365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9366         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9367         return ret_ref;
9368 }
9369
9370 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
9371         LDKCommitmentSigned ret = *owner->contents.result;
9372         ret.is_owned = false;
9373         return ret;
9374 }
9375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9376         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
9377         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
9378         int64_t ret_ref = 0;
9379         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9380         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9381         return ret_ref;
9382 }
9383
9384 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
9385         LDKDecodeError ret = *owner->contents.err;
9386         ret.is_owned = false;
9387         return ret;
9388 }
9389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9390         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
9391         LDKDecodeError ret_var = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
9392         int64_t ret_ref = 0;
9393         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9394         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9395         return ret_ref;
9396 }
9397
9398 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
9399         LDKFundingCreated ret = *owner->contents.result;
9400         ret.is_owned = false;
9401         return ret;
9402 }
9403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9404         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
9405         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
9406         int64_t ret_ref = 0;
9407         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9408         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9409         return ret_ref;
9410 }
9411
9412 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
9413         LDKDecodeError ret = *owner->contents.err;
9414         ret.is_owned = false;
9415         return ret;
9416 }
9417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9418         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
9419         LDKDecodeError ret_var = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
9420         int64_t ret_ref = 0;
9421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9422         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9423         return ret_ref;
9424 }
9425
9426 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
9427         LDKFundingSigned ret = *owner->contents.result;
9428         ret.is_owned = false;
9429         return ret;
9430 }
9431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9432         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
9433         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
9434         int64_t ret_ref = 0;
9435         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9436         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9437         return ret_ref;
9438 }
9439
9440 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
9441         LDKDecodeError ret = *owner->contents.err;
9442         ret.is_owned = false;
9443         return ret;
9444 }
9445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9446         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
9447         LDKDecodeError ret_var = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
9448         int64_t ret_ref = 0;
9449         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9450         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9451         return ret_ref;
9452 }
9453
9454 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
9455         LDKChannelReady ret = *owner->contents.result;
9456         ret.is_owned = false;
9457         return ret;
9458 }
9459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9460         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
9461         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
9462         int64_t ret_ref = 0;
9463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9464         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9465         return ret_ref;
9466 }
9467
9468 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
9469         LDKDecodeError ret = *owner->contents.err;
9470         ret.is_owned = false;
9471         return ret;
9472 }
9473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9474         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
9475         LDKDecodeError ret_var = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
9476         int64_t ret_ref = 0;
9477         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9478         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9479         return ret_ref;
9480 }
9481
9482 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
9483         LDKInit ret = *owner->contents.result;
9484         ret.is_owned = false;
9485         return ret;
9486 }
9487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9488         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
9489         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
9490         int64_t ret_ref = 0;
9491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9492         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9493         return ret_ref;
9494 }
9495
9496 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
9497         LDKDecodeError ret = *owner->contents.err;
9498         ret.is_owned = false;
9499         return ret;
9500 }
9501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9502         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
9503         LDKDecodeError ret_var = CResult_InitDecodeErrorZ_get_err(owner_conv);
9504         int64_t ret_ref = 0;
9505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9506         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9507         return ret_ref;
9508 }
9509
9510 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
9511         LDKOpenChannel ret = *owner->contents.result;
9512         ret.is_owned = false;
9513         return ret;
9514 }
9515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9516         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
9517         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
9518         int64_t ret_ref = 0;
9519         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9520         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9521         return ret_ref;
9522 }
9523
9524 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
9525         LDKDecodeError ret = *owner->contents.err;
9526         ret.is_owned = false;
9527         return ret;
9528 }
9529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9530         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
9531         LDKDecodeError ret_var = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
9532         int64_t ret_ref = 0;
9533         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9534         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9535         return ret_ref;
9536 }
9537
9538 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
9539         LDKRevokeAndACK ret = *owner->contents.result;
9540         ret.is_owned = false;
9541         return ret;
9542 }
9543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9544         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
9545         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
9546         int64_t ret_ref = 0;
9547         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9548         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9549         return ret_ref;
9550 }
9551
9552 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
9553         LDKDecodeError ret = *owner->contents.err;
9554         ret.is_owned = false;
9555         return ret;
9556 }
9557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9558         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
9559         LDKDecodeError ret_var = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
9560         int64_t ret_ref = 0;
9561         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9562         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9563         return ret_ref;
9564 }
9565
9566 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
9567         LDKShutdown ret = *owner->contents.result;
9568         ret.is_owned = false;
9569         return ret;
9570 }
9571 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9572         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
9573         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
9574         int64_t ret_ref = 0;
9575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9576         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9577         return ret_ref;
9578 }
9579
9580 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
9581         LDKDecodeError ret = *owner->contents.err;
9582         ret.is_owned = false;
9583         return ret;
9584 }
9585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9586         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
9587         LDKDecodeError ret_var = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
9588         int64_t ret_ref = 0;
9589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9590         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9591         return ret_ref;
9592 }
9593
9594 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
9595         LDKUpdateFailHTLC ret = *owner->contents.result;
9596         ret.is_owned = false;
9597         return ret;
9598 }
9599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9600         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
9601         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
9602         int64_t ret_ref = 0;
9603         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9604         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9605         return ret_ref;
9606 }
9607
9608 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
9609         LDKDecodeError ret = *owner->contents.err;
9610         ret.is_owned = false;
9611         return ret;
9612 }
9613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9614         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
9615         LDKDecodeError ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
9616         int64_t ret_ref = 0;
9617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9618         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9619         return ret_ref;
9620 }
9621
9622 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
9623         LDKUpdateFailMalformedHTLC ret = *owner->contents.result;
9624         ret.is_owned = false;
9625         return ret;
9626 }
9627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9628         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
9629         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
9630         int64_t ret_ref = 0;
9631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9632         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9633         return ret_ref;
9634 }
9635
9636 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
9637         LDKDecodeError ret = *owner->contents.err;
9638         ret.is_owned = false;
9639         return ret;
9640 }
9641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9642         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
9643         LDKDecodeError ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
9644         int64_t ret_ref = 0;
9645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9646         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9647         return ret_ref;
9648 }
9649
9650 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
9651         LDKUpdateFee ret = *owner->contents.result;
9652         ret.is_owned = false;
9653         return ret;
9654 }
9655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9656         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
9657         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
9658         int64_t ret_ref = 0;
9659         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9660         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9661         return ret_ref;
9662 }
9663
9664 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
9665         LDKDecodeError ret = *owner->contents.err;
9666         ret.is_owned = false;
9667         return ret;
9668 }
9669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9670         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
9671         LDKDecodeError ret_var = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
9672         int64_t ret_ref = 0;
9673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9674         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9675         return ret_ref;
9676 }
9677
9678 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9679         LDKUpdateFulfillHTLC ret = *owner->contents.result;
9680         ret.is_owned = false;
9681         return ret;
9682 }
9683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9684         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
9685         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
9686         int64_t ret_ref = 0;
9687         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9688         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9689         return ret_ref;
9690 }
9691
9692 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
9693         LDKDecodeError ret = *owner->contents.err;
9694         ret.is_owned = false;
9695         return ret;
9696 }
9697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9698         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
9699         LDKDecodeError ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
9700         int64_t ret_ref = 0;
9701         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9702         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9703         return ret_ref;
9704 }
9705
9706 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9707         LDKUpdateAddHTLC ret = *owner->contents.result;
9708         ret.is_owned = false;
9709         return ret;
9710 }
9711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9712         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
9713         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
9714         int64_t ret_ref = 0;
9715         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9716         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9717         return ret_ref;
9718 }
9719
9720 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
9721         LDKDecodeError ret = *owner->contents.err;
9722         ret.is_owned = false;
9723         return ret;
9724 }
9725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9726         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
9727         LDKDecodeError ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
9728         int64_t ret_ref = 0;
9729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9730         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9731         return ret_ref;
9732 }
9733
9734 static inline struct LDKOnionMessage CResult_OnionMessageDecodeErrorZ_get_ok(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR owner){
9735         LDKOnionMessage ret = *owner->contents.result;
9736         ret.is_owned = false;
9737         return ret;
9738 }
9739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9740         LDKCResult_OnionMessageDecodeErrorZ* owner_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(owner);
9741         LDKOnionMessage ret_var = CResult_OnionMessageDecodeErrorZ_get_ok(owner_conv);
9742         int64_t ret_ref = 0;
9743         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9744         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9745         return ret_ref;
9746 }
9747
9748 static inline struct LDKDecodeError CResult_OnionMessageDecodeErrorZ_get_err(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR owner){
9749         LDKDecodeError ret = *owner->contents.err;
9750         ret.is_owned = false;
9751         return ret;
9752 }
9753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9754         LDKCResult_OnionMessageDecodeErrorZ* owner_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(owner);
9755         LDKDecodeError ret_var = CResult_OnionMessageDecodeErrorZ_get_err(owner_conv);
9756         int64_t ret_ref = 0;
9757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9758         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9759         return ret_ref;
9760 }
9761
9762 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9763         LDKPing ret = *owner->contents.result;
9764         ret.is_owned = false;
9765         return ret;
9766 }
9767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9768         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
9769         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
9770         int64_t ret_ref = 0;
9771         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9772         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9773         return ret_ref;
9774 }
9775
9776 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
9777         LDKDecodeError ret = *owner->contents.err;
9778         ret.is_owned = false;
9779         return ret;
9780 }
9781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9782         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
9783         LDKDecodeError ret_var = CResult_PingDecodeErrorZ_get_err(owner_conv);
9784         int64_t ret_ref = 0;
9785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9786         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9787         return ret_ref;
9788 }
9789
9790 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9791         LDKPong ret = *owner->contents.result;
9792         ret.is_owned = false;
9793         return ret;
9794 }
9795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9796         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
9797         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
9798         int64_t ret_ref = 0;
9799         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9800         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9801         return ret_ref;
9802 }
9803
9804 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
9805         LDKDecodeError ret = *owner->contents.err;
9806         ret.is_owned = false;
9807         return ret;
9808 }
9809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9810         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
9811         LDKDecodeError ret_var = CResult_PongDecodeErrorZ_get_err(owner_conv);
9812         int64_t ret_ref = 0;
9813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9814         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9815         return ret_ref;
9816 }
9817
9818 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9819         LDKUnsignedChannelAnnouncement ret = *owner->contents.result;
9820         ret.is_owned = false;
9821         return ret;
9822 }
9823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9824         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
9825         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
9826         int64_t ret_ref = 0;
9827         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9828         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9829         return ret_ref;
9830 }
9831
9832 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9833         LDKDecodeError ret = *owner->contents.err;
9834         ret.is_owned = false;
9835         return ret;
9836 }
9837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9838         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
9839         LDKDecodeError ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
9840         int64_t ret_ref = 0;
9841         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9842         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9843         return ret_ref;
9844 }
9845
9846 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9847         LDKChannelAnnouncement ret = *owner->contents.result;
9848         ret.is_owned = false;
9849         return ret;
9850 }
9851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9852         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
9853         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
9854         int64_t ret_ref = 0;
9855         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9856         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9857         return ret_ref;
9858 }
9859
9860 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9861         LDKDecodeError ret = *owner->contents.err;
9862         ret.is_owned = false;
9863         return ret;
9864 }
9865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9866         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
9867         LDKDecodeError ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
9868         int64_t ret_ref = 0;
9869         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9870         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9871         return ret_ref;
9872 }
9873
9874 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9875         LDKUnsignedChannelUpdate ret = *owner->contents.result;
9876         ret.is_owned = false;
9877         return ret;
9878 }
9879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9880         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
9881         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
9882         int64_t ret_ref = 0;
9883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9884         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9885         return ret_ref;
9886 }
9887
9888 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9889         LDKDecodeError ret = *owner->contents.err;
9890         ret.is_owned = false;
9891         return ret;
9892 }
9893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9894         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
9895         LDKDecodeError ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
9896         int64_t ret_ref = 0;
9897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9898         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9899         return ret_ref;
9900 }
9901
9902 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9903         LDKChannelUpdate ret = *owner->contents.result;
9904         ret.is_owned = false;
9905         return ret;
9906 }
9907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9908         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
9909         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
9910         int64_t ret_ref = 0;
9911         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9912         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9913         return ret_ref;
9914 }
9915
9916 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
9917         LDKDecodeError ret = *owner->contents.err;
9918         ret.is_owned = false;
9919         return ret;
9920 }
9921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9922         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
9923         LDKDecodeError ret_var = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
9924         int64_t ret_ref = 0;
9925         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9926         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9927         return ret_ref;
9928 }
9929
9930 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9931         LDKErrorMessage ret = *owner->contents.result;
9932         ret.is_owned = false;
9933         return ret;
9934 }
9935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9936         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
9937         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
9938         int64_t ret_ref = 0;
9939         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9940         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9941         return ret_ref;
9942 }
9943
9944 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
9945         LDKDecodeError ret = *owner->contents.err;
9946         ret.is_owned = false;
9947         return ret;
9948 }
9949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9950         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
9951         LDKDecodeError ret_var = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
9952         int64_t ret_ref = 0;
9953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9954         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9955         return ret_ref;
9956 }
9957
9958 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9959         LDKWarningMessage ret = *owner->contents.result;
9960         ret.is_owned = false;
9961         return ret;
9962 }
9963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9964         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
9965         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
9966         int64_t ret_ref = 0;
9967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9968         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9969         return ret_ref;
9970 }
9971
9972 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
9973         LDKDecodeError ret = *owner->contents.err;
9974         ret.is_owned = false;
9975         return ret;
9976 }
9977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9978         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
9979         LDKDecodeError ret_var = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
9980         int64_t ret_ref = 0;
9981         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9982         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9983         return ret_ref;
9984 }
9985
9986 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
9987         LDKUnsignedNodeAnnouncement ret = *owner->contents.result;
9988         ret.is_owned = false;
9989         return ret;
9990 }
9991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9992         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
9993         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
9994         int64_t ret_ref = 0;
9995         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9996         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9997         return ret_ref;
9998 }
9999
10000 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10001         LDKDecodeError ret = *owner->contents.err;
10002         ret.is_owned = false;
10003         return ret;
10004 }
10005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10006         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
10007         LDKDecodeError ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
10008         int64_t ret_ref = 0;
10009         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10010         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10011         return ret_ref;
10012 }
10013
10014 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10015         LDKNodeAnnouncement ret = *owner->contents.result;
10016         ret.is_owned = false;
10017         return ret;
10018 }
10019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10020         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
10021         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
10022         int64_t ret_ref = 0;
10023         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10024         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10025         return ret_ref;
10026 }
10027
10028 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10029         LDKDecodeError ret = *owner->contents.err;
10030         ret.is_owned = false;
10031         return ret;
10032 }
10033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10034         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
10035         LDKDecodeError ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
10036         int64_t ret_ref = 0;
10037         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10038         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10039         return ret_ref;
10040 }
10041
10042 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
10043         LDKQueryShortChannelIds ret = *owner->contents.result;
10044         ret.is_owned = false;
10045         return ret;
10046 }
10047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10048         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
10049         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
10050         int64_t ret_ref = 0;
10051         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10052         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10053         return ret_ref;
10054 }
10055
10056 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
10057         LDKDecodeError ret = *owner->contents.err;
10058         ret.is_owned = false;
10059         return ret;
10060 }
10061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10062         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
10063         LDKDecodeError ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
10064         int64_t ret_ref = 0;
10065         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10066         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10067         return ret_ref;
10068 }
10069
10070 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
10071         LDKReplyShortChannelIdsEnd ret = *owner->contents.result;
10072         ret.is_owned = false;
10073         return ret;
10074 }
10075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10076         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
10077         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
10078         int64_t ret_ref = 0;
10079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10080         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10081         return ret_ref;
10082 }
10083
10084 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
10085         LDKDecodeError ret = *owner->contents.err;
10086         ret.is_owned = false;
10087         return ret;
10088 }
10089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10090         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
10091         LDKDecodeError ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
10092         int64_t ret_ref = 0;
10093         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10094         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10095         return ret_ref;
10096 }
10097
10098 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10099         LDKQueryChannelRange ret = *owner->contents.result;
10100         ret.is_owned = false;
10101         return ret;
10102 }
10103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10104         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
10105         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
10106         int64_t ret_ref = 0;
10107         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10108         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10109         return ret_ref;
10110 }
10111
10112 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10113         LDKDecodeError ret = *owner->contents.err;
10114         ret.is_owned = false;
10115         return ret;
10116 }
10117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10118         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
10119         LDKDecodeError ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
10120         int64_t ret_ref = 0;
10121         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10122         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10123         return ret_ref;
10124 }
10125
10126 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10127         LDKReplyChannelRange ret = *owner->contents.result;
10128         ret.is_owned = false;
10129         return ret;
10130 }
10131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10132         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
10133         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
10134         int64_t ret_ref = 0;
10135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10136         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10137         return ret_ref;
10138 }
10139
10140 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10141         LDKDecodeError ret = *owner->contents.err;
10142         ret.is_owned = false;
10143         return ret;
10144 }
10145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10146         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
10147         LDKDecodeError ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
10148         int64_t ret_ref = 0;
10149         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10150         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10151         return ret_ref;
10152 }
10153
10154 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
10155         LDKGossipTimestampFilter ret = *owner->contents.result;
10156         ret.is_owned = false;
10157         return ret;
10158 }
10159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10160         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
10161         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
10162         int64_t ret_ref = 0;
10163         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10164         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10165         return ret_ref;
10166 }
10167
10168 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
10169         LDKDecodeError ret = *owner->contents.err;
10170         ret.is_owned = false;
10171         return ret;
10172 }
10173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10174         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
10175         LDKDecodeError ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
10176         int64_t ret_ref = 0;
10177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10178         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10179         return ret_ref;
10180 }
10181
10182 static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
10183         LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
10184         for (size_t i = 0; i < ret.datalen; i++) {
10185                 ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
10186         }
10187         return ret;
10188 }
10189 static jclass LDKSignOrCreationError_SignError_class = NULL;
10190 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
10191 static jclass LDKSignOrCreationError_CreationError_class = NULL;
10192 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
10193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
10194         LDKSignOrCreationError_SignError_class =
10195                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
10196         CHECK(LDKSignOrCreationError_SignError_class != NULL);
10197         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
10198         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
10199         LDKSignOrCreationError_CreationError_class =
10200                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
10201         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
10202         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
10203         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
10204 }
10205 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10206         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)untag_ptr(ptr);
10207         switch(obj->tag) {
10208                 case LDKSignOrCreationError_SignError: {
10209                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
10210                 }
10211                 case LDKSignOrCreationError_CreationError: {
10212                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
10213                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
10214                 }
10215                 default: abort();
10216         }
10217 }
10218 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
10219         LDKInvoice ret = *owner->contents.result;
10220         ret.is_owned = false;
10221         return ret;
10222 }
10223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10224         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
10225         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
10226         int64_t ret_ref = 0;
10227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10228         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10229         return ret_ref;
10230 }
10231
10232 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
10233 CHECK(!owner->result_ok);
10234         return SignOrCreationError_clone(&*owner->contents.err);
10235 }
10236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10237         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
10238         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
10239         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
10240         int64_t ret_ref = tag_ptr(ret_copy, true);
10241         return ret_ref;
10242 }
10243
10244 typedef struct LDKFilter_JCalls {
10245         atomic_size_t refcnt;
10246         JavaVM *vm;
10247         jweak o;
10248         jmethodID register_tx_meth;
10249         jmethodID register_output_meth;
10250 } LDKFilter_JCalls;
10251 static void LDKFilter_JCalls_free(void* this_arg) {
10252         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10253         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10254                 JNIEnv *env;
10255                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10256                 if (get_jenv_res == JNI_EDETACHED) {
10257                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10258                 } else {
10259                         DO_ASSERT(get_jenv_res == JNI_OK);
10260                 }
10261                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10262                 if (get_jenv_res == JNI_EDETACHED) {
10263                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10264                 }
10265                 FREE(j_calls);
10266         }
10267 }
10268 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
10269         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10270         JNIEnv *env;
10271         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10272         if (get_jenv_res == JNI_EDETACHED) {
10273                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10274         } else {
10275                 DO_ASSERT(get_jenv_res == JNI_OK);
10276         }
10277         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
10278         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
10279         LDKu8slice script_pubkey_var = script_pubkey;
10280         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
10281         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
10282         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10283         CHECK(obj != NULL);
10284         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
10285         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10286                 (*env)->ExceptionDescribe(env);
10287                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
10288         }
10289         if (get_jenv_res == JNI_EDETACHED) {
10290                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10291         }
10292 }
10293 void register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
10294         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10295         JNIEnv *env;
10296         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10297         if (get_jenv_res == JNI_EDETACHED) {
10298                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10299         } else {
10300                 DO_ASSERT(get_jenv_res == JNI_OK);
10301         }
10302         LDKWatchedOutput output_var = output;
10303         int64_t output_ref = 0;
10304         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
10305         output_ref = tag_ptr(output_var.inner, output_var.is_owned);
10306         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10307         CHECK(obj != NULL);
10308         (*env)->CallVoidMethod(env, obj, j_calls->register_output_meth, output_ref);
10309         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10310                 (*env)->ExceptionDescribe(env);
10311                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
10312         }
10313         if (get_jenv_res == JNI_EDETACHED) {
10314                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10315         }
10316 }
10317 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
10318         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
10319         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10320 }
10321 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
10322         jclass c = (*env)->GetObjectClass(env, o);
10323         CHECK(c != NULL);
10324         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
10325         atomic_init(&calls->refcnt, 1);
10326         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10327         calls->o = (*env)->NewWeakGlobalRef(env, o);
10328         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
10329         CHECK(calls->register_tx_meth != NULL);
10330         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)V");
10331         CHECK(calls->register_output_meth != NULL);
10332
10333         LDKFilter ret = {
10334                 .this_arg = (void*) calls,
10335                 .register_tx = register_tx_LDKFilter_jcall,
10336                 .register_output = register_output_LDKFilter_jcall,
10337                 .free = LDKFilter_JCalls_free,
10338         };
10339         return ret;
10340 }
10341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
10342         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
10343         *res_ptr = LDKFilter_init(env, clz, o);
10344         return tag_ptr(res_ptr, true);
10345 }
10346 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) {
10347         void* this_arg_ptr = untag_ptr(this_arg);
10348         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10349         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
10350         unsigned char txid_arr[32];
10351         CHECK((*env)->GetArrayLength(env, txid) == 32);
10352         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
10353         unsigned char (*txid_ref)[32] = &txid_arr;
10354         LDKu8slice script_pubkey_ref;
10355         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
10356         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
10357         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
10358         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
10359 }
10360
10361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
10362         void* this_arg_ptr = untag_ptr(this_arg);
10363         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10364         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
10365         LDKWatchedOutput output_conv;
10366         output_conv.inner = untag_ptr(output);
10367         output_conv.is_owned = ptr_is_owned(output);
10368         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
10369         output_conv = WatchedOutput_clone(&output_conv);
10370         (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
10371 }
10372
10373 static jclass LDKCOption_FilterZ_Some_class = NULL;
10374 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
10375 static jclass LDKCOption_FilterZ_None_class = NULL;
10376 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
10377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
10378         LDKCOption_FilterZ_Some_class =
10379                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
10380         CHECK(LDKCOption_FilterZ_Some_class != NULL);
10381         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
10382         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
10383         LDKCOption_FilterZ_None_class =
10384                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
10385         CHECK(LDKCOption_FilterZ_None_class != NULL);
10386         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
10387         CHECK(LDKCOption_FilterZ_None_meth != NULL);
10388 }
10389 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10390         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)untag_ptr(ptr);
10391         switch(obj->tag) {
10392                 case LDKCOption_FilterZ_Some: {
10393                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
10394                         *some_ret = obj->some;
10395                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
10396                         if ((*some_ret).free == LDKFilter_JCalls_free) {
10397                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10398                                 LDKFilter_JCalls_cloned(&(*some_ret));
10399                         }
10400                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, tag_ptr(some_ret, true));
10401                 }
10402                 case LDKCOption_FilterZ_None: {
10403                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
10404                 }
10405                 default: abort();
10406         }
10407 }
10408 static inline struct LDKLockedChannelMonitor CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
10409         LDKLockedChannelMonitor ret = *owner->contents.result;
10410         ret.is_owned = false;
10411         return ret;
10412 }
10413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10414         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
10415         LDKLockedChannelMonitor ret_var = CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
10416         int64_t ret_ref = 0;
10417         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10418         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10419         return ret_ref;
10420 }
10421
10422 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
10423 CHECK(!owner->result_ok);
10424         return *owner->contents.err;
10425 }
10426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10427         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
10428         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
10429 }
10430
10431 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
10432         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
10433         for (size_t i = 0; i < ret.datalen; i++) {
10434                 ret.data[i] = OutPoint_clone(&orig->data[i]);
10435         }
10436         return ret;
10437 }
10438 typedef struct LDKMessageSendEventsProvider_JCalls {
10439         atomic_size_t refcnt;
10440         JavaVM *vm;
10441         jweak o;
10442         jmethodID get_and_clear_pending_msg_events_meth;
10443 } LDKMessageSendEventsProvider_JCalls;
10444 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
10445         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
10446         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10447                 JNIEnv *env;
10448                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10449                 if (get_jenv_res == JNI_EDETACHED) {
10450                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10451                 } else {
10452                         DO_ASSERT(get_jenv_res == JNI_OK);
10453                 }
10454                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10455                 if (get_jenv_res == JNI_EDETACHED) {
10456                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10457                 }
10458                 FREE(j_calls);
10459         }
10460 }
10461 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
10462         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
10463         JNIEnv *env;
10464         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10465         if (get_jenv_res == JNI_EDETACHED) {
10466                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10467         } else {
10468                 DO_ASSERT(get_jenv_res == JNI_OK);
10469         }
10470         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10471         CHECK(obj != NULL);
10472         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
10473         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10474                 (*env)->ExceptionDescribe(env);
10475                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
10476         }
10477         LDKCVec_MessageSendEventZ ret_constr;
10478         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
10479         if (ret_constr.datalen > 0)
10480                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
10481         else
10482                 ret_constr.data = NULL;
10483         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
10484         for (size_t s = 0; s < ret_constr.datalen; s++) {
10485                 int64_t ret_conv_18 = ret_vals[s];
10486                 void* ret_conv_18_ptr = untag_ptr(ret_conv_18);
10487                 CHECK_ACCESS(ret_conv_18_ptr);
10488                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
10489                 FREE(untag_ptr(ret_conv_18));
10490                 ret_constr.data[s] = ret_conv_18_conv;
10491         }
10492         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
10493         if (get_jenv_res == JNI_EDETACHED) {
10494                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10495         }
10496         return ret_constr;
10497 }
10498 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
10499         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
10500         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10501 }
10502 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10503         jclass c = (*env)->GetObjectClass(env, o);
10504         CHECK(c != NULL);
10505         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
10506         atomic_init(&calls->refcnt, 1);
10507         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10508         calls->o = (*env)->NewWeakGlobalRef(env, o);
10509         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
10510         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
10511
10512         LDKMessageSendEventsProvider ret = {
10513                 .this_arg = (void*) calls,
10514                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
10515                 .free = LDKMessageSendEventsProvider_JCalls_free,
10516         };
10517         return ret;
10518 }
10519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10520         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
10521         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
10522         return tag_ptr(res_ptr, true);
10523 }
10524 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
10525         void* this_arg_ptr = untag_ptr(this_arg);
10526         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10527         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
10528         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
10529         int64_tArray ret_arr = NULL;
10530         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10531         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10532         for (size_t s = 0; s < ret_var.datalen; s++) {
10533                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
10534                 *ret_conv_18_copy = ret_var.data[s];
10535                 int64_t ret_conv_18_ref = tag_ptr(ret_conv_18_copy, true);
10536                 ret_arr_ptr[s] = ret_conv_18_ref;
10537         }
10538         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10539         FREE(ret_var.data);
10540         return ret_arr;
10541 }
10542
10543 typedef struct LDKOnionMessageProvider_JCalls {
10544         atomic_size_t refcnt;
10545         JavaVM *vm;
10546         jweak o;
10547         jmethodID next_onion_message_for_peer_meth;
10548 } LDKOnionMessageProvider_JCalls;
10549 static void LDKOnionMessageProvider_JCalls_free(void* this_arg) {
10550         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) this_arg;
10551         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10552                 JNIEnv *env;
10553                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10554                 if (get_jenv_res == JNI_EDETACHED) {
10555                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10556                 } else {
10557                         DO_ASSERT(get_jenv_res == JNI_OK);
10558                 }
10559                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10560                 if (get_jenv_res == JNI_EDETACHED) {
10561                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10562                 }
10563                 FREE(j_calls);
10564         }
10565 }
10566 LDKOnionMessage next_onion_message_for_peer_LDKOnionMessageProvider_jcall(const void* this_arg, LDKPublicKey peer_node_id) {
10567         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) this_arg;
10568         JNIEnv *env;
10569         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10570         if (get_jenv_res == JNI_EDETACHED) {
10571                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10572         } else {
10573                 DO_ASSERT(get_jenv_res == JNI_OK);
10574         }
10575         int8_tArray peer_node_id_arr = (*env)->NewByteArray(env, 33);
10576         (*env)->SetByteArrayRegion(env, peer_node_id_arr, 0, 33, peer_node_id.compressed_form);
10577         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10578         CHECK(obj != NULL);
10579         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->next_onion_message_for_peer_meth, peer_node_id_arr);
10580         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10581                 (*env)->ExceptionDescribe(env);
10582                 (*env)->FatalError(env, "A call to next_onion_message_for_peer in LDKOnionMessageProvider from rust threw an exception.");
10583         }
10584         LDKOnionMessage ret_conv;
10585         ret_conv.inner = untag_ptr(ret);
10586         ret_conv.is_owned = ptr_is_owned(ret);
10587         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
10588         if (get_jenv_res == JNI_EDETACHED) {
10589                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10590         }
10591         return ret_conv;
10592 }
10593 static void LDKOnionMessageProvider_JCalls_cloned(LDKOnionMessageProvider* new_obj) {
10594         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) new_obj->this_arg;
10595         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10596 }
10597 static inline LDKOnionMessageProvider LDKOnionMessageProvider_init (JNIEnv *env, jclass clz, jobject o) {
10598         jclass c = (*env)->GetObjectClass(env, o);
10599         CHECK(c != NULL);
10600         LDKOnionMessageProvider_JCalls *calls = MALLOC(sizeof(LDKOnionMessageProvider_JCalls), "LDKOnionMessageProvider_JCalls");
10601         atomic_init(&calls->refcnt, 1);
10602         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10603         calls->o = (*env)->NewWeakGlobalRef(env, o);
10604         calls->next_onion_message_for_peer_meth = (*env)->GetMethodID(env, c, "next_onion_message_for_peer", "([B)J");
10605         CHECK(calls->next_onion_message_for_peer_meth != NULL);
10606
10607         LDKOnionMessageProvider ret = {
10608                 .this_arg = (void*) calls,
10609                 .next_onion_message_for_peer = next_onion_message_for_peer_LDKOnionMessageProvider_jcall,
10610                 .free = LDKOnionMessageProvider_JCalls_free,
10611         };
10612         return ret;
10613 }
10614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10615         LDKOnionMessageProvider *res_ptr = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
10616         *res_ptr = LDKOnionMessageProvider_init(env, clz, o);
10617         return tag_ptr(res_ptr, true);
10618 }
10619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageProvider_1next_1onion_1message_1for_1peer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray peer_node_id) {
10620         void* this_arg_ptr = untag_ptr(this_arg);
10621         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10622         LDKOnionMessageProvider* this_arg_conv = (LDKOnionMessageProvider*)this_arg_ptr;
10623         LDKPublicKey peer_node_id_ref;
10624         CHECK((*env)->GetArrayLength(env, peer_node_id) == 33);
10625         (*env)->GetByteArrayRegion(env, peer_node_id, 0, 33, peer_node_id_ref.compressed_form);
10626         LDKOnionMessage ret_var = (this_arg_conv->next_onion_message_for_peer)(this_arg_conv->this_arg, peer_node_id_ref);
10627         int64_t ret_ref = 0;
10628         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10629         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10630         return ret_ref;
10631 }
10632
10633 typedef struct LDKEventHandler_JCalls {
10634         atomic_size_t refcnt;
10635         JavaVM *vm;
10636         jweak o;
10637         jmethodID handle_event_meth;
10638 } LDKEventHandler_JCalls;
10639 static void LDKEventHandler_JCalls_free(void* this_arg) {
10640         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10641         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10642                 JNIEnv *env;
10643                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10644                 if (get_jenv_res == JNI_EDETACHED) {
10645                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10646                 } else {
10647                         DO_ASSERT(get_jenv_res == JNI_OK);
10648                 }
10649                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10650                 if (get_jenv_res == JNI_EDETACHED) {
10651                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10652                 }
10653                 FREE(j_calls);
10654         }
10655 }
10656 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
10657         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
10658         JNIEnv *env;
10659         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10660         if (get_jenv_res == JNI_EDETACHED) {
10661                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10662         } else {
10663                 DO_ASSERT(get_jenv_res == JNI_OK);
10664         }
10665         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
10666         *ret_event = Event_clone(event);
10667         int64_t ref_event = tag_ptr(ret_event, true);
10668         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10669         CHECK(obj != NULL);
10670         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, ref_event);
10671         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10672                 (*env)->ExceptionDescribe(env);
10673                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
10674         }
10675         if (get_jenv_res == JNI_EDETACHED) {
10676                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10677         }
10678 }
10679 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
10680         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
10681         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10682 }
10683 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
10684         jclass c = (*env)->GetObjectClass(env, o);
10685         CHECK(c != NULL);
10686         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
10687         atomic_init(&calls->refcnt, 1);
10688         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10689         calls->o = (*env)->NewWeakGlobalRef(env, o);
10690         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
10691         CHECK(calls->handle_event_meth != NULL);
10692
10693         LDKEventHandler ret = {
10694                 .this_arg = (void*) calls,
10695                 .handle_event = handle_event_LDKEventHandler_jcall,
10696                 .free = LDKEventHandler_JCalls_free,
10697         };
10698         return ret;
10699 }
10700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
10701         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10702         *res_ptr = LDKEventHandler_init(env, clz, o);
10703         return tag_ptr(res_ptr, true);
10704 }
10705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
10706         void* this_arg_ptr = untag_ptr(this_arg);
10707         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10708         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
10709         LDKEvent* event_conv = (LDKEvent*)untag_ptr(event);
10710         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
10711 }
10712
10713 typedef struct LDKEventsProvider_JCalls {
10714         atomic_size_t refcnt;
10715         JavaVM *vm;
10716         jweak o;
10717         jmethodID process_pending_events_meth;
10718 } LDKEventsProvider_JCalls;
10719 static void LDKEventsProvider_JCalls_free(void* this_arg) {
10720         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10721         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10722                 JNIEnv *env;
10723                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10724                 if (get_jenv_res == JNI_EDETACHED) {
10725                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10726                 } else {
10727                         DO_ASSERT(get_jenv_res == JNI_OK);
10728                 }
10729                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10730                 if (get_jenv_res == JNI_EDETACHED) {
10731                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10732                 }
10733                 FREE(j_calls);
10734         }
10735 }
10736 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
10737         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
10738         JNIEnv *env;
10739         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10740         if (get_jenv_res == JNI_EDETACHED) {
10741                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10742         } else {
10743                 DO_ASSERT(get_jenv_res == JNI_OK);
10744         }
10745         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
10746         *handler_ret = handler;
10747         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10748         CHECK(obj != NULL);
10749         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, tag_ptr(handler_ret, true));
10750         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10751                 (*env)->ExceptionDescribe(env);
10752                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
10753         }
10754         if (get_jenv_res == JNI_EDETACHED) {
10755                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10756         }
10757 }
10758 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
10759         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
10760         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10761 }
10762 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10763         jclass c = (*env)->GetObjectClass(env, o);
10764         CHECK(c != NULL);
10765         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
10766         atomic_init(&calls->refcnt, 1);
10767         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10768         calls->o = (*env)->NewWeakGlobalRef(env, o);
10769         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
10770         CHECK(calls->process_pending_events_meth != NULL);
10771
10772         LDKEventsProvider ret = {
10773                 .this_arg = (void*) calls,
10774                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
10775                 .free = LDKEventsProvider_JCalls_free,
10776         };
10777         return ret;
10778 }
10779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10780         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
10781         *res_ptr = LDKEventsProvider_init(env, clz, o);
10782         return tag_ptr(res_ptr, true);
10783 }
10784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
10785         void* this_arg_ptr = untag_ptr(this_arg);
10786         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10787         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
10788         void* handler_ptr = untag_ptr(handler);
10789         CHECK_ACCESS(handler_ptr);
10790         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
10791         if (handler_conv.free == LDKEventHandler_JCalls_free) {
10792                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10793                 LDKEventHandler_JCalls_cloned(&handler_conv);
10794         }
10795         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
10796 }
10797
10798 typedef struct LDKPersister_JCalls {
10799         atomic_size_t refcnt;
10800         JavaVM *vm;
10801         jweak o;
10802         jmethodID persist_manager_meth;
10803         jmethodID persist_graph_meth;
10804         jmethodID persist_scorer_meth;
10805 } LDKPersister_JCalls;
10806 static void LDKPersister_JCalls_free(void* this_arg) {
10807         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
10808         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10809                 JNIEnv *env;
10810                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10811                 if (get_jenv_res == JNI_EDETACHED) {
10812                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10813                 } else {
10814                         DO_ASSERT(get_jenv_res == JNI_OK);
10815                 }
10816                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10817                 if (get_jenv_res == JNI_EDETACHED) {
10818                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10819                 }
10820                 FREE(j_calls);
10821         }
10822 }
10823 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
10824         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
10825         JNIEnv *env;
10826         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10827         if (get_jenv_res == JNI_EDETACHED) {
10828                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10829         } else {
10830                 DO_ASSERT(get_jenv_res == JNI_OK);
10831         }
10832         LDKChannelManager channel_manager_var = *channel_manager;
10833         int64_t channel_manager_ref = 0;
10834         // WARNING: we may need a move here but no clone is available for LDKChannelManager
10835         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
10836         channel_manager_ref = tag_ptr(channel_manager_var.inner, channel_manager_var.is_owned);
10837         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10838         CHECK(obj != NULL);
10839         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
10840         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10841                 (*env)->ExceptionDescribe(env);
10842                 (*env)->FatalError(env, "A call to persist_manager in LDKPersister from rust threw an exception.");
10843         }
10844         void* ret_ptr = untag_ptr(ret);
10845         CHECK_ACCESS(ret_ptr);
10846         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
10847         FREE(untag_ptr(ret));
10848         if (get_jenv_res == JNI_EDETACHED) {
10849                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10850         }
10851         return ret_conv;
10852 }
10853 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
10854         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
10855         JNIEnv *env;
10856         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10857         if (get_jenv_res == JNI_EDETACHED) {
10858                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10859         } else {
10860                 DO_ASSERT(get_jenv_res == JNI_OK);
10861         }
10862         LDKNetworkGraph network_graph_var = *network_graph;
10863         int64_t network_graph_ref = 0;
10864         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
10865         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
10866         network_graph_ref = tag_ptr(network_graph_var.inner, network_graph_var.is_owned);
10867         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10868         CHECK(obj != NULL);
10869         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_graph_meth, network_graph_ref);
10870         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10871                 (*env)->ExceptionDescribe(env);
10872                 (*env)->FatalError(env, "A call to persist_graph in LDKPersister from rust threw an exception.");
10873         }
10874         void* ret_ptr = untag_ptr(ret);
10875         CHECK_ACCESS(ret_ptr);
10876         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
10877         FREE(untag_ptr(ret));
10878         if (get_jenv_res == JNI_EDETACHED) {
10879                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10880         }
10881         return ret_conv;
10882 }
10883 LDKCResult_NoneErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKWriteableScore * scorer) {
10884         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
10885         JNIEnv *env;
10886         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10887         if (get_jenv_res == JNI_EDETACHED) {
10888                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10889         } else {
10890                 DO_ASSERT(get_jenv_res == JNI_OK);
10891         }
10892         // WARNING: This object doesn't live past this scope, needs clone!
10893         int64_t ret_scorer = tag_ptr(scorer, false);
10894         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10895         CHECK(obj != NULL);
10896         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_scorer_meth, ret_scorer);
10897         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10898                 (*env)->ExceptionDescribe(env);
10899                 (*env)->FatalError(env, "A call to persist_scorer in LDKPersister from rust threw an exception.");
10900         }
10901         void* ret_ptr = untag_ptr(ret);
10902         CHECK_ACCESS(ret_ptr);
10903         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
10904         FREE(untag_ptr(ret));
10905         if (get_jenv_res == JNI_EDETACHED) {
10906                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10907         }
10908         return ret_conv;
10909 }
10910 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
10911         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
10912         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10913 }
10914 static inline LDKPersister LDKPersister_init (JNIEnv *env, jclass clz, jobject o) {
10915         jclass c = (*env)->GetObjectClass(env, o);
10916         CHECK(c != NULL);
10917         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
10918         atomic_init(&calls->refcnt, 1);
10919         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10920         calls->o = (*env)->NewWeakGlobalRef(env, o);
10921         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
10922         CHECK(calls->persist_manager_meth != NULL);
10923         calls->persist_graph_meth = (*env)->GetMethodID(env, c, "persist_graph", "(J)J");
10924         CHECK(calls->persist_graph_meth != NULL);
10925         calls->persist_scorer_meth = (*env)->GetMethodID(env, c, "persist_scorer", "(J)J");
10926         CHECK(calls->persist_scorer_meth != NULL);
10927
10928         LDKPersister ret = {
10929                 .this_arg = (void*) calls,
10930                 .persist_manager = persist_manager_LDKPersister_jcall,
10931                 .persist_graph = persist_graph_LDKPersister_jcall,
10932                 .persist_scorer = persist_scorer_LDKPersister_jcall,
10933                 .free = LDKPersister_JCalls_free,
10934         };
10935         return ret;
10936 }
10937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersister_1new(JNIEnv *env, jclass clz, jobject o) {
10938         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
10939         *res_ptr = LDKPersister_init(env, clz, o);
10940         return tag_ptr(res_ptr, true);
10941 }
10942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
10943         void* this_arg_ptr = untag_ptr(this_arg);
10944         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10945         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
10946         LDKChannelManager channel_manager_conv;
10947         channel_manager_conv.inner = untag_ptr(channel_manager);
10948         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
10949         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
10950         channel_manager_conv.is_owned = false;
10951         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10952         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
10953         return tag_ptr(ret_conv, true);
10954 }
10955
10956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_graph) {
10957         void* this_arg_ptr = untag_ptr(this_arg);
10958         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10959         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
10960         LDKNetworkGraph network_graph_conv;
10961         network_graph_conv.inner = untag_ptr(network_graph);
10962         network_graph_conv.is_owned = ptr_is_owned(network_graph);
10963         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
10964         network_graph_conv.is_owned = false;
10965         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10966         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
10967         return tag_ptr(ret_conv, true);
10968 }
10969
10970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1scorer(JNIEnv *env, jclass clz, int64_t this_arg, int64_t scorer) {
10971         void* this_arg_ptr = untag_ptr(this_arg);
10972         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10973         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
10974         void* scorer_ptr = untag_ptr(scorer);
10975         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
10976         LDKWriteableScore* scorer_conv = (LDKWriteableScore*)scorer_ptr;
10977         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10978         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, scorer_conv);
10979         return tag_ptr(ret_conv, true);
10980 }
10981
10982 typedef struct LDKFutureCallback_JCalls {
10983         atomic_size_t refcnt;
10984         JavaVM *vm;
10985         jweak o;
10986         jmethodID call_meth;
10987 } LDKFutureCallback_JCalls;
10988 static void LDKFutureCallback_JCalls_free(void* this_arg) {
10989         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) this_arg;
10990         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10991                 JNIEnv *env;
10992                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10993                 if (get_jenv_res == JNI_EDETACHED) {
10994                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10995                 } else {
10996                         DO_ASSERT(get_jenv_res == JNI_OK);
10997                 }
10998                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10999                 if (get_jenv_res == JNI_EDETACHED) {
11000                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11001                 }
11002                 FREE(j_calls);
11003         }
11004 }
11005 void call_LDKFutureCallback_jcall(const void* this_arg) {
11006         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) this_arg;
11007         JNIEnv *env;
11008         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11009         if (get_jenv_res == JNI_EDETACHED) {
11010                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11011         } else {
11012                 DO_ASSERT(get_jenv_res == JNI_OK);
11013         }
11014         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11015         CHECK(obj != NULL);
11016         (*env)->CallVoidMethod(env, obj, j_calls->call_meth);
11017         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11018                 (*env)->ExceptionDescribe(env);
11019                 (*env)->FatalError(env, "A call to call in LDKFutureCallback from rust threw an exception.");
11020         }
11021         if (get_jenv_res == JNI_EDETACHED) {
11022                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11023         }
11024 }
11025 static void LDKFutureCallback_JCalls_cloned(LDKFutureCallback* new_obj) {
11026         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) new_obj->this_arg;
11027         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11028 }
11029 static inline LDKFutureCallback LDKFutureCallback_init (JNIEnv *env, jclass clz, jobject o) {
11030         jclass c = (*env)->GetObjectClass(env, o);
11031         CHECK(c != NULL);
11032         LDKFutureCallback_JCalls *calls = MALLOC(sizeof(LDKFutureCallback_JCalls), "LDKFutureCallback_JCalls");
11033         atomic_init(&calls->refcnt, 1);
11034         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11035         calls->o = (*env)->NewWeakGlobalRef(env, o);
11036         calls->call_meth = (*env)->GetMethodID(env, c, "call", "()V");
11037         CHECK(calls->call_meth != NULL);
11038
11039         LDKFutureCallback ret = {
11040                 .this_arg = (void*) calls,
11041                 .call = call_LDKFutureCallback_jcall,
11042                 .free = LDKFutureCallback_JCalls_free,
11043         };
11044         return ret;
11045 }
11046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFutureCallback_1new(JNIEnv *env, jclass clz, jobject o) {
11047         LDKFutureCallback *res_ptr = MALLOC(sizeof(LDKFutureCallback), "LDKFutureCallback");
11048         *res_ptr = LDKFutureCallback_init(env, clz, o);
11049         return tag_ptr(res_ptr, true);
11050 }
11051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FutureCallback_1call(JNIEnv *env, jclass clz, int64_t this_arg) {
11052         void* this_arg_ptr = untag_ptr(this_arg);
11053         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11054         LDKFutureCallback* this_arg_conv = (LDKFutureCallback*)this_arg_ptr;
11055         (this_arg_conv->call)(this_arg_conv->this_arg);
11056 }
11057
11058 typedef struct LDKListen_JCalls {
11059         atomic_size_t refcnt;
11060         JavaVM *vm;
11061         jweak o;
11062         jmethodID filtered_block_connected_meth;
11063         jmethodID block_connected_meth;
11064         jmethodID block_disconnected_meth;
11065 } LDKListen_JCalls;
11066 static void LDKListen_JCalls_free(void* this_arg) {
11067         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11068         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11069                 JNIEnv *env;
11070                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11071                 if (get_jenv_res == JNI_EDETACHED) {
11072                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11073                 } else {
11074                         DO_ASSERT(get_jenv_res == JNI_OK);
11075                 }
11076                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11077                 if (get_jenv_res == JNI_EDETACHED) {
11078                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11079                 }
11080                 FREE(j_calls);
11081         }
11082 }
11083 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
11084         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11085         JNIEnv *env;
11086         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11087         if (get_jenv_res == JNI_EDETACHED) {
11088                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11089         } else {
11090                 DO_ASSERT(get_jenv_res == JNI_OK);
11091         }
11092         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11093         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11094         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
11095         int64_tArray txdata_arr = NULL;
11096         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
11097         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
11098         for (size_t c = 0; c < txdata_var.datalen; c++) {
11099                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11100                 *txdata_conv_28_conv = txdata_var.data[c];
11101                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
11102         }
11103         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
11104         FREE(txdata_var.data);
11105         int32_t height_conv = height;
11106         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11107         CHECK(obj != NULL);
11108         (*env)->CallVoidMethod(env, obj, j_calls->filtered_block_connected_meth, header_arr, txdata_arr, height_conv);
11109         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11110                 (*env)->ExceptionDescribe(env);
11111                 (*env)->FatalError(env, "A call to filtered_block_connected in LDKListen from rust threw an exception.");
11112         }
11113         if (get_jenv_res == JNI_EDETACHED) {
11114                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11115         }
11116 }
11117 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
11118         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11119         JNIEnv *env;
11120         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11121         if (get_jenv_res == JNI_EDETACHED) {
11122                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11123         } else {
11124                 DO_ASSERT(get_jenv_res == JNI_OK);
11125         }
11126         LDKu8slice block_var = block;
11127         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
11128         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
11129         int32_t height_conv = height;
11130         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11131         CHECK(obj != NULL);
11132         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height_conv);
11133         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11134                 (*env)->ExceptionDescribe(env);
11135                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
11136         }
11137         if (get_jenv_res == JNI_EDETACHED) {
11138                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11139         }
11140 }
11141 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
11142         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11143         JNIEnv *env;
11144         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11145         if (get_jenv_res == JNI_EDETACHED) {
11146                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11147         } else {
11148                 DO_ASSERT(get_jenv_res == JNI_OK);
11149         }
11150         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11151         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11152         int32_t height_conv = height;
11153         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11154         CHECK(obj != NULL);
11155         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height_conv);
11156         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11157                 (*env)->ExceptionDescribe(env);
11158                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
11159         }
11160         if (get_jenv_res == JNI_EDETACHED) {
11161                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11162         }
11163 }
11164 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
11165         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
11166         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11167 }
11168 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
11169         jclass c = (*env)->GetObjectClass(env, o);
11170         CHECK(c != NULL);
11171         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
11172         atomic_init(&calls->refcnt, 1);
11173         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11174         calls->o = (*env)->NewWeakGlobalRef(env, o);
11175         calls->filtered_block_connected_meth = (*env)->GetMethodID(env, c, "filtered_block_connected", "([B[JI)V");
11176         CHECK(calls->filtered_block_connected_meth != NULL);
11177         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
11178         CHECK(calls->block_connected_meth != NULL);
11179         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
11180         CHECK(calls->block_disconnected_meth != NULL);
11181
11182         LDKListen ret = {
11183                 .this_arg = (void*) calls,
11184                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
11185                 .block_connected = block_connected_LDKListen_jcall,
11186                 .block_disconnected = block_disconnected_LDKListen_jcall,
11187                 .free = LDKListen_JCalls_free,
11188         };
11189         return ret;
11190 }
11191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
11192         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
11193         *res_ptr = LDKListen_init(env, clz, o);
11194         return tag_ptr(res_ptr, true);
11195 }
11196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1filtered_1block_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray header, int64_tArray txdata, int32_t height) {
11197         void* this_arg_ptr = untag_ptr(this_arg);
11198         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11199         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11200         unsigned char header_arr[80];
11201         CHECK((*env)->GetArrayLength(env, header) == 80);
11202         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11203         unsigned char (*header_ref)[80] = &header_arr;
11204         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11205         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11206         if (txdata_constr.datalen > 0)
11207                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11208         else
11209                 txdata_constr.data = NULL;
11210         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11211         for (size_t c = 0; c < txdata_constr.datalen; c++) {
11212                 int64_t txdata_conv_28 = txdata_vals[c];
11213                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
11214                 CHECK_ACCESS(txdata_conv_28_ptr);
11215                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
11216                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
11217                 txdata_constr.data[c] = txdata_conv_28_conv;
11218         }
11219         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11220         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
11221 }
11222
11223 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) {
11224         void* this_arg_ptr = untag_ptr(this_arg);
11225         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11226         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11227         LDKu8slice block_ref;
11228         block_ref.datalen = (*env)->GetArrayLength(env, block);
11229         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
11230         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
11231         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
11232 }
11233
11234 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) {
11235         void* this_arg_ptr = untag_ptr(this_arg);
11236         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11237         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11238         unsigned char header_arr[80];
11239         CHECK((*env)->GetArrayLength(env, header) == 80);
11240         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11241         unsigned char (*header_ref)[80] = &header_arr;
11242         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
11243 }
11244
11245 typedef struct LDKConfirm_JCalls {
11246         atomic_size_t refcnt;
11247         JavaVM *vm;
11248         jweak o;
11249         jmethodID transactions_confirmed_meth;
11250         jmethodID transaction_unconfirmed_meth;
11251         jmethodID best_block_updated_meth;
11252         jmethodID get_relevant_txids_meth;
11253 } LDKConfirm_JCalls;
11254 static void LDKConfirm_JCalls_free(void* this_arg) {
11255         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11256         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11257                 JNIEnv *env;
11258                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11259                 if (get_jenv_res == JNI_EDETACHED) {
11260                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11261                 } else {
11262                         DO_ASSERT(get_jenv_res == JNI_OK);
11263                 }
11264                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11265                 if (get_jenv_res == JNI_EDETACHED) {
11266                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11267                 }
11268                 FREE(j_calls);
11269         }
11270 }
11271 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
11272         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11273         JNIEnv *env;
11274         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11275         if (get_jenv_res == JNI_EDETACHED) {
11276                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11277         } else {
11278                 DO_ASSERT(get_jenv_res == JNI_OK);
11279         }
11280         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11281         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11282         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
11283         int64_tArray txdata_arr = NULL;
11284         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
11285         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
11286         for (size_t c = 0; c < txdata_var.datalen; c++) {
11287                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11288                 *txdata_conv_28_conv = txdata_var.data[c];
11289                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
11290         }
11291         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
11292         FREE(txdata_var.data);
11293         int32_t height_conv = height;
11294         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11295         CHECK(obj != NULL);
11296         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height_conv);
11297         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11298                 (*env)->ExceptionDescribe(env);
11299                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
11300         }
11301         if (get_jenv_res == JNI_EDETACHED) {
11302                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11303         }
11304 }
11305 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
11306         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11307         JNIEnv *env;
11308         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11309         if (get_jenv_res == JNI_EDETACHED) {
11310                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11311         } else {
11312                 DO_ASSERT(get_jenv_res == JNI_OK);
11313         }
11314         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
11315         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
11316         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11317         CHECK(obj != NULL);
11318         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
11319         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11320                 (*env)->ExceptionDescribe(env);
11321                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
11322         }
11323         if (get_jenv_res == JNI_EDETACHED) {
11324                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11325         }
11326 }
11327 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
11328         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11329         JNIEnv *env;
11330         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11331         if (get_jenv_res == JNI_EDETACHED) {
11332                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11333         } else {
11334                 DO_ASSERT(get_jenv_res == JNI_OK);
11335         }
11336         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11337         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11338         int32_t height_conv = height;
11339         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11340         CHECK(obj != NULL);
11341         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height_conv);
11342         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11343                 (*env)->ExceptionDescribe(env);
11344                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
11345         }
11346         if (get_jenv_res == JNI_EDETACHED) {
11347                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11348         }
11349 }
11350 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
11351         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11352         JNIEnv *env;
11353         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11354         if (get_jenv_res == JNI_EDETACHED) {
11355                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11356         } else {
11357                 DO_ASSERT(get_jenv_res == JNI_OK);
11358         }
11359         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11360         CHECK(obj != NULL);
11361         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
11362         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11363                 (*env)->ExceptionDescribe(env);
11364                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
11365         }
11366         LDKCVec_TxidZ ret_constr;
11367         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11368         if (ret_constr.datalen > 0)
11369                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
11370         else
11371                 ret_constr.data = NULL;
11372         for (size_t i = 0; i < ret_constr.datalen; i++) {
11373                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
11374                 LDKThirtyTwoBytes ret_conv_8_ref;
11375                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
11376                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
11377                 ret_constr.data[i] = ret_conv_8_ref;
11378         }
11379         if (get_jenv_res == JNI_EDETACHED) {
11380                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11381         }
11382         return ret_constr;
11383 }
11384 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
11385         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
11386         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11387 }
11388 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
11389         jclass c = (*env)->GetObjectClass(env, o);
11390         CHECK(c != NULL);
11391         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
11392         atomic_init(&calls->refcnt, 1);
11393         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11394         calls->o = (*env)->NewWeakGlobalRef(env, o);
11395         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
11396         CHECK(calls->transactions_confirmed_meth != NULL);
11397         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
11398         CHECK(calls->transaction_unconfirmed_meth != NULL);
11399         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
11400         CHECK(calls->best_block_updated_meth != NULL);
11401         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
11402         CHECK(calls->get_relevant_txids_meth != NULL);
11403
11404         LDKConfirm ret = {
11405                 .this_arg = (void*) calls,
11406                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
11407                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
11408                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
11409                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
11410                 .free = LDKConfirm_JCalls_free,
11411         };
11412         return ret;
11413 }
11414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
11415         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
11416         *res_ptr = LDKConfirm_init(env, clz, o);
11417         return tag_ptr(res_ptr, true);
11418 }
11419 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) {
11420         void* this_arg_ptr = untag_ptr(this_arg);
11421         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11422         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11423         unsigned char header_arr[80];
11424         CHECK((*env)->GetArrayLength(env, header) == 80);
11425         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11426         unsigned char (*header_ref)[80] = &header_arr;
11427         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11428         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11429         if (txdata_constr.datalen > 0)
11430                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11431         else
11432                 txdata_constr.data = NULL;
11433         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11434         for (size_t c = 0; c < txdata_constr.datalen; c++) {
11435                 int64_t txdata_conv_28 = txdata_vals[c];
11436                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
11437                 CHECK_ACCESS(txdata_conv_28_ptr);
11438                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
11439                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
11440                 txdata_constr.data[c] = txdata_conv_28_conv;
11441         }
11442         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11443         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
11444 }
11445
11446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
11447         void* this_arg_ptr = untag_ptr(this_arg);
11448         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11449         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11450         unsigned char txid_arr[32];
11451         CHECK((*env)->GetArrayLength(env, txid) == 32);
11452         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
11453         unsigned char (*txid_ref)[32] = &txid_arr;
11454         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
11455 }
11456
11457 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) {
11458         void* this_arg_ptr = untag_ptr(this_arg);
11459         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11460         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11461         unsigned char header_arr[80];
11462         CHECK((*env)->GetArrayLength(env, header) == 80);
11463         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11464         unsigned char (*header_ref)[80] = &header_arr;
11465         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
11466 }
11467
11468 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
11469         void* this_arg_ptr = untag_ptr(this_arg);
11470         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11471         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11472         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
11473         jobjectArray ret_arr = NULL;
11474         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
11475         ;
11476         for (size_t i = 0; i < ret_var.datalen; i++) {
11477                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
11478                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
11479                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
11480         }
11481         
11482         FREE(ret_var.data);
11483         return ret_arr;
11484 }
11485
11486 typedef struct LDKPersist_JCalls {
11487         atomic_size_t refcnt;
11488         JavaVM *vm;
11489         jweak o;
11490         jmethodID persist_new_channel_meth;
11491         jmethodID update_persisted_channel_meth;
11492 } LDKPersist_JCalls;
11493 static void LDKPersist_JCalls_free(void* this_arg) {
11494         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11495         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11496                 JNIEnv *env;
11497                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11498                 if (get_jenv_res == JNI_EDETACHED) {
11499                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11500                 } else {
11501                         DO_ASSERT(get_jenv_res == JNI_OK);
11502                 }
11503                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11504                 if (get_jenv_res == JNI_EDETACHED) {
11505                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11506                 }
11507                 FREE(j_calls);
11508         }
11509 }
11510 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
11511         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11512         JNIEnv *env;
11513         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11514         if (get_jenv_res == JNI_EDETACHED) {
11515                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11516         } else {
11517                 DO_ASSERT(get_jenv_res == JNI_OK);
11518         }
11519         LDKOutPoint channel_id_var = channel_id;
11520         int64_t channel_id_ref = 0;
11521         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
11522         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
11523         LDKChannelMonitor data_var = *data;
11524         int64_t data_ref = 0;
11525         data_var = ChannelMonitor_clone(&data_var);
11526         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
11527         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
11528         LDKMonitorUpdateId update_id_var = update_id;
11529         int64_t update_id_ref = 0;
11530         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
11531         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
11532         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11533         CHECK(obj != NULL);
11534         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
11535         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11536                 (*env)->ExceptionDescribe(env);
11537                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
11538         }
11539         void* ret_ptr = untag_ptr(ret);
11540         CHECK_ACCESS(ret_ptr);
11541         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
11542         FREE(untag_ptr(ret));
11543         if (get_jenv_res == JNI_EDETACHED) {
11544                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11545         }
11546         return ret_conv;
11547 }
11548 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
11549         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11550         JNIEnv *env;
11551         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11552         if (get_jenv_res == JNI_EDETACHED) {
11553                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11554         } else {
11555                 DO_ASSERT(get_jenv_res == JNI_OK);
11556         }
11557         LDKOutPoint channel_id_var = channel_id;
11558         int64_t channel_id_ref = 0;
11559         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
11560         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
11561         LDKChannelMonitorUpdate update_var = *update;
11562         int64_t update_ref = 0;
11563         update_var = ChannelMonitorUpdate_clone(&update_var);
11564         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
11565         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
11566         LDKChannelMonitor data_var = *data;
11567         int64_t data_ref = 0;
11568         data_var = ChannelMonitor_clone(&data_var);
11569         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
11570         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
11571         LDKMonitorUpdateId update_id_var = update_id;
11572         int64_t update_id_ref = 0;
11573         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
11574         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
11575         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11576         CHECK(obj != NULL);
11577         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
11578         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11579                 (*env)->ExceptionDescribe(env);
11580                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
11581         }
11582         void* ret_ptr = untag_ptr(ret);
11583         CHECK_ACCESS(ret_ptr);
11584         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
11585         FREE(untag_ptr(ret));
11586         if (get_jenv_res == JNI_EDETACHED) {
11587                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11588         }
11589         return ret_conv;
11590 }
11591 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
11592         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
11593         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11594 }
11595 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
11596         jclass c = (*env)->GetObjectClass(env, o);
11597         CHECK(c != NULL);
11598         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
11599         atomic_init(&calls->refcnt, 1);
11600         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11601         calls->o = (*env)->NewWeakGlobalRef(env, o);
11602         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)J");
11603         CHECK(calls->persist_new_channel_meth != NULL);
11604         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)J");
11605         CHECK(calls->update_persisted_channel_meth != NULL);
11606
11607         LDKPersist ret = {
11608                 .this_arg = (void*) calls,
11609                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
11610                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
11611                 .free = LDKPersist_JCalls_free,
11612         };
11613         return ret;
11614 }
11615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
11616         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
11617         *res_ptr = LDKPersist_init(env, clz, o);
11618         return tag_ptr(res_ptr, true);
11619 }
11620 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) {
11621         void* this_arg_ptr = untag_ptr(this_arg);
11622         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11623         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
11624         LDKOutPoint channel_id_conv;
11625         channel_id_conv.inner = untag_ptr(channel_id);
11626         channel_id_conv.is_owned = ptr_is_owned(channel_id);
11627         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
11628         channel_id_conv = OutPoint_clone(&channel_id_conv);
11629         LDKChannelMonitor data_conv;
11630         data_conv.inner = untag_ptr(data);
11631         data_conv.is_owned = ptr_is_owned(data);
11632         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
11633         data_conv.is_owned = false;
11634         LDKMonitorUpdateId update_id_conv;
11635         update_id_conv.inner = untag_ptr(update_id);
11636         update_id_conv.is_owned = ptr_is_owned(update_id);
11637         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
11638         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
11639         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11640         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
11641         return tag_ptr(ret_conv, true);
11642 }
11643
11644 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) {
11645         void* this_arg_ptr = untag_ptr(this_arg);
11646         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11647         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
11648         LDKOutPoint channel_id_conv;
11649         channel_id_conv.inner = untag_ptr(channel_id);
11650         channel_id_conv.is_owned = ptr_is_owned(channel_id);
11651         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
11652         channel_id_conv = OutPoint_clone(&channel_id_conv);
11653         LDKChannelMonitorUpdate update_conv;
11654         update_conv.inner = untag_ptr(update);
11655         update_conv.is_owned = ptr_is_owned(update);
11656         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
11657         update_conv.is_owned = false;
11658         LDKChannelMonitor data_conv;
11659         data_conv.inner = untag_ptr(data);
11660         data_conv.is_owned = ptr_is_owned(data);
11661         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
11662         data_conv.is_owned = false;
11663         LDKMonitorUpdateId update_id_conv;
11664         update_id_conv.inner = untag_ptr(update_id);
11665         update_id_conv.is_owned = ptr_is_owned(update_id);
11666         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
11667         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
11668         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
11669         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
11670         return tag_ptr(ret_conv, true);
11671 }
11672
11673 typedef struct LDKChannelMessageHandler_JCalls {
11674         atomic_size_t refcnt;
11675         JavaVM *vm;
11676         jweak o;
11677         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
11678         jmethodID handle_open_channel_meth;
11679         jmethodID handle_accept_channel_meth;
11680         jmethodID handle_funding_created_meth;
11681         jmethodID handle_funding_signed_meth;
11682         jmethodID handle_channel_ready_meth;
11683         jmethodID handle_shutdown_meth;
11684         jmethodID handle_closing_signed_meth;
11685         jmethodID handle_update_add_htlc_meth;
11686         jmethodID handle_update_fulfill_htlc_meth;
11687         jmethodID handle_update_fail_htlc_meth;
11688         jmethodID handle_update_fail_malformed_htlc_meth;
11689         jmethodID handle_commitment_signed_meth;
11690         jmethodID handle_revoke_and_ack_meth;
11691         jmethodID handle_update_fee_meth;
11692         jmethodID handle_announcement_signatures_meth;
11693         jmethodID peer_disconnected_meth;
11694         jmethodID peer_connected_meth;
11695         jmethodID handle_channel_reestablish_meth;
11696         jmethodID handle_channel_update_meth;
11697         jmethodID handle_error_meth;
11698         jmethodID provided_node_features_meth;
11699         jmethodID provided_init_features_meth;
11700 } LDKChannelMessageHandler_JCalls;
11701 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
11702         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11703         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11704                 JNIEnv *env;
11705                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11706                 if (get_jenv_res == JNI_EDETACHED) {
11707                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11708                 } else {
11709                         DO_ASSERT(get_jenv_res == JNI_OK);
11710                 }
11711                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11712                 if (get_jenv_res == JNI_EDETACHED) {
11713                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11714                 }
11715                 FREE(j_calls);
11716         }
11717 }
11718 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
11719         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11720         JNIEnv *env;
11721         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11722         if (get_jenv_res == JNI_EDETACHED) {
11723                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11724         } else {
11725                 DO_ASSERT(get_jenv_res == JNI_OK);
11726         }
11727         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11728         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11729         LDKInitFeatures their_features_var = their_features;
11730         int64_t their_features_ref = 0;
11731         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11732         their_features_ref = tag_ptr(their_features_var.inner, their_features_var.is_owned);
11733         LDKOpenChannel msg_var = *msg;
11734         int64_t msg_ref = 0;
11735         msg_var = OpenChannel_clone(&msg_var);
11736         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11737         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11738         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11739         CHECK(obj != NULL);
11740         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
11741         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11742                 (*env)->ExceptionDescribe(env);
11743                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
11744         }
11745         if (get_jenv_res == JNI_EDETACHED) {
11746                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11747         }
11748 }
11749 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
11750         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11751         JNIEnv *env;
11752         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11753         if (get_jenv_res == JNI_EDETACHED) {
11754                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11755         } else {
11756                 DO_ASSERT(get_jenv_res == JNI_OK);
11757         }
11758         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11759         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11760         LDKInitFeatures their_features_var = their_features;
11761         int64_t their_features_ref = 0;
11762         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11763         their_features_ref = tag_ptr(their_features_var.inner, their_features_var.is_owned);
11764         LDKAcceptChannel msg_var = *msg;
11765         int64_t msg_ref = 0;
11766         msg_var = AcceptChannel_clone(&msg_var);
11767         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11768         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11769         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11770         CHECK(obj != NULL);
11771         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
11772         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11773                 (*env)->ExceptionDescribe(env);
11774                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
11775         }
11776         if (get_jenv_res == JNI_EDETACHED) {
11777                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11778         }
11779 }
11780 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
11781         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11782         JNIEnv *env;
11783         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11784         if (get_jenv_res == JNI_EDETACHED) {
11785                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11786         } else {
11787                 DO_ASSERT(get_jenv_res == JNI_OK);
11788         }
11789         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11790         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11791         LDKFundingCreated msg_var = *msg;
11792         int64_t msg_ref = 0;
11793         msg_var = FundingCreated_clone(&msg_var);
11794         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11795         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11796         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11797         CHECK(obj != NULL);
11798         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
11799         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11800                 (*env)->ExceptionDescribe(env);
11801                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
11802         }
11803         if (get_jenv_res == JNI_EDETACHED) {
11804                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11805         }
11806 }
11807 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
11808         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11809         JNIEnv *env;
11810         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11811         if (get_jenv_res == JNI_EDETACHED) {
11812                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11813         } else {
11814                 DO_ASSERT(get_jenv_res == JNI_OK);
11815         }
11816         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11817         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11818         LDKFundingSigned msg_var = *msg;
11819         int64_t msg_ref = 0;
11820         msg_var = FundingSigned_clone(&msg_var);
11821         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11822         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11823         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11824         CHECK(obj != NULL);
11825         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
11826         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11827                 (*env)->ExceptionDescribe(env);
11828                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
11829         }
11830         if (get_jenv_res == JNI_EDETACHED) {
11831                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11832         }
11833 }
11834 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
11835         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11836         JNIEnv *env;
11837         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11838         if (get_jenv_res == JNI_EDETACHED) {
11839                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11840         } else {
11841                 DO_ASSERT(get_jenv_res == JNI_OK);
11842         }
11843         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11844         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11845         LDKChannelReady msg_var = *msg;
11846         int64_t msg_ref = 0;
11847         msg_var = ChannelReady_clone(&msg_var);
11848         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11849         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11850         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11851         CHECK(obj != NULL);
11852         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_ready_meth, their_node_id_arr, msg_ref);
11853         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11854                 (*env)->ExceptionDescribe(env);
11855                 (*env)->FatalError(env, "A call to handle_channel_ready in LDKChannelMessageHandler from rust threw an exception.");
11856         }
11857         if (get_jenv_res == JNI_EDETACHED) {
11858                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11859         }
11860 }
11861 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
11862         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11863         JNIEnv *env;
11864         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11865         if (get_jenv_res == JNI_EDETACHED) {
11866                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11867         } else {
11868                 DO_ASSERT(get_jenv_res == JNI_OK);
11869         }
11870         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11871         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11872         LDKInitFeatures their_features_var = *their_features;
11873         int64_t their_features_ref = 0;
11874         their_features_var = InitFeatures_clone(&their_features_var);
11875         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
11876         their_features_ref = tag_ptr(their_features_var.inner, their_features_var.is_owned);
11877         LDKShutdown msg_var = *msg;
11878         int64_t msg_ref = 0;
11879         msg_var = Shutdown_clone(&msg_var);
11880         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11881         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11882         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11883         CHECK(obj != NULL);
11884         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
11885         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11886                 (*env)->ExceptionDescribe(env);
11887                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
11888         }
11889         if (get_jenv_res == JNI_EDETACHED) {
11890                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11891         }
11892 }
11893 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
11894         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11895         JNIEnv *env;
11896         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11897         if (get_jenv_res == JNI_EDETACHED) {
11898                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11899         } else {
11900                 DO_ASSERT(get_jenv_res == JNI_OK);
11901         }
11902         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11903         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11904         LDKClosingSigned msg_var = *msg;
11905         int64_t msg_ref = 0;
11906         msg_var = ClosingSigned_clone(&msg_var);
11907         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11908         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11909         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11910         CHECK(obj != NULL);
11911         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
11912         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11913                 (*env)->ExceptionDescribe(env);
11914                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
11915         }
11916         if (get_jenv_res == JNI_EDETACHED) {
11917                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11918         }
11919 }
11920 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
11921         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11922         JNIEnv *env;
11923         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11924         if (get_jenv_res == JNI_EDETACHED) {
11925                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11926         } else {
11927                 DO_ASSERT(get_jenv_res == JNI_OK);
11928         }
11929         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11930         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11931         LDKUpdateAddHTLC msg_var = *msg;
11932         int64_t msg_ref = 0;
11933         msg_var = UpdateAddHTLC_clone(&msg_var);
11934         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11935         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11936         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11937         CHECK(obj != NULL);
11938         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
11939         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11940                 (*env)->ExceptionDescribe(env);
11941                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
11942         }
11943         if (get_jenv_res == JNI_EDETACHED) {
11944                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11945         }
11946 }
11947 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
11948         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11949         JNIEnv *env;
11950         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11951         if (get_jenv_res == JNI_EDETACHED) {
11952                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11953         } else {
11954                 DO_ASSERT(get_jenv_res == JNI_OK);
11955         }
11956         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11957         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11958         LDKUpdateFulfillHTLC msg_var = *msg;
11959         int64_t msg_ref = 0;
11960         msg_var = UpdateFulfillHTLC_clone(&msg_var);
11961         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11962         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11963         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11964         CHECK(obj != NULL);
11965         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
11966         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11967                 (*env)->ExceptionDescribe(env);
11968                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
11969         }
11970         if (get_jenv_res == JNI_EDETACHED) {
11971                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11972         }
11973 }
11974 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
11975         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
11976         JNIEnv *env;
11977         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11978         if (get_jenv_res == JNI_EDETACHED) {
11979                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11980         } else {
11981                 DO_ASSERT(get_jenv_res == JNI_OK);
11982         }
11983         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
11984         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
11985         LDKUpdateFailHTLC msg_var = *msg;
11986         int64_t msg_ref = 0;
11987         msg_var = UpdateFailHTLC_clone(&msg_var);
11988         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
11989         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
11990         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11991         CHECK(obj != NULL);
11992         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
11993         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11994                 (*env)->ExceptionDescribe(env);
11995                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
11996         }
11997         if (get_jenv_res == JNI_EDETACHED) {
11998                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11999         }
12000 }
12001 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
12002         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12003         JNIEnv *env;
12004         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12005         if (get_jenv_res == JNI_EDETACHED) {
12006                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12007         } else {
12008                 DO_ASSERT(get_jenv_res == JNI_OK);
12009         }
12010         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12011         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12012         LDKUpdateFailMalformedHTLC msg_var = *msg;
12013         int64_t msg_ref = 0;
12014         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
12015         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12016         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12017         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12018         CHECK(obj != NULL);
12019         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
12020         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12021                 (*env)->ExceptionDescribe(env);
12022                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
12023         }
12024         if (get_jenv_res == JNI_EDETACHED) {
12025                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12026         }
12027 }
12028 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
12029         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12030         JNIEnv *env;
12031         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12032         if (get_jenv_res == JNI_EDETACHED) {
12033                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12034         } else {
12035                 DO_ASSERT(get_jenv_res == JNI_OK);
12036         }
12037         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12038         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12039         LDKCommitmentSigned msg_var = *msg;
12040         int64_t msg_ref = 0;
12041         msg_var = CommitmentSigned_clone(&msg_var);
12042         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12043         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12044         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12045         CHECK(obj != NULL);
12046         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
12047         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12048                 (*env)->ExceptionDescribe(env);
12049                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
12050         }
12051         if (get_jenv_res == JNI_EDETACHED) {
12052                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12053         }
12054 }
12055 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
12056         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12057         JNIEnv *env;
12058         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12059         if (get_jenv_res == JNI_EDETACHED) {
12060                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12061         } else {
12062                 DO_ASSERT(get_jenv_res == JNI_OK);
12063         }
12064         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12065         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12066         LDKRevokeAndACK msg_var = *msg;
12067         int64_t msg_ref = 0;
12068         msg_var = RevokeAndACK_clone(&msg_var);
12069         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12070         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12071         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12072         CHECK(obj != NULL);
12073         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
12074         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12075                 (*env)->ExceptionDescribe(env);
12076                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
12077         }
12078         if (get_jenv_res == JNI_EDETACHED) {
12079                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12080         }
12081 }
12082 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
12083         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12084         JNIEnv *env;
12085         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12086         if (get_jenv_res == JNI_EDETACHED) {
12087                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12088         } else {
12089                 DO_ASSERT(get_jenv_res == JNI_OK);
12090         }
12091         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12092         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12093         LDKUpdateFee msg_var = *msg;
12094         int64_t msg_ref = 0;
12095         msg_var = UpdateFee_clone(&msg_var);
12096         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12097         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12098         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12099         CHECK(obj != NULL);
12100         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
12101         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12102                 (*env)->ExceptionDescribe(env);
12103                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
12104         }
12105         if (get_jenv_res == JNI_EDETACHED) {
12106                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12107         }
12108 }
12109 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
12110         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12111         JNIEnv *env;
12112         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12113         if (get_jenv_res == JNI_EDETACHED) {
12114                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12115         } else {
12116                 DO_ASSERT(get_jenv_res == JNI_OK);
12117         }
12118         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12119         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12120         LDKAnnouncementSignatures msg_var = *msg;
12121         int64_t msg_ref = 0;
12122         msg_var = AnnouncementSignatures_clone(&msg_var);
12123         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12124         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12125         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12126         CHECK(obj != NULL);
12127         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
12128         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12129                 (*env)->ExceptionDescribe(env);
12130                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
12131         }
12132         if (get_jenv_res == JNI_EDETACHED) {
12133                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12134         }
12135 }
12136 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
12137         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12138         JNIEnv *env;
12139         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12140         if (get_jenv_res == JNI_EDETACHED) {
12141                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12142         } else {
12143                 DO_ASSERT(get_jenv_res == JNI_OK);
12144         }
12145         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12146         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12147         jboolean no_connection_possible_conv = no_connection_possible;
12148         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12149         CHECK(obj != NULL);
12150         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible_conv);
12151         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12152                 (*env)->ExceptionDescribe(env);
12153                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
12154         }
12155         if (get_jenv_res == JNI_EDETACHED) {
12156                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12157         }
12158 }
12159 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
12160         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12161         JNIEnv *env;
12162         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12163         if (get_jenv_res == JNI_EDETACHED) {
12164                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12165         } else {
12166                 DO_ASSERT(get_jenv_res == JNI_OK);
12167         }
12168         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12169         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12170         LDKInit msg_var = *msg;
12171         int64_t msg_ref = 0;
12172         msg_var = Init_clone(&msg_var);
12173         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12174         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12175         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12176         CHECK(obj != NULL);
12177         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
12178         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12179                 (*env)->ExceptionDescribe(env);
12180                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
12181         }
12182         if (get_jenv_res == JNI_EDETACHED) {
12183                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12184         }
12185 }
12186 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
12187         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12188         JNIEnv *env;
12189         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12190         if (get_jenv_res == JNI_EDETACHED) {
12191                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12192         } else {
12193                 DO_ASSERT(get_jenv_res == JNI_OK);
12194         }
12195         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12196         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12197         LDKChannelReestablish msg_var = *msg;
12198         int64_t msg_ref = 0;
12199         msg_var = ChannelReestablish_clone(&msg_var);
12200         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12201         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12202         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12203         CHECK(obj != NULL);
12204         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
12205         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12206                 (*env)->ExceptionDescribe(env);
12207                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
12208         }
12209         if (get_jenv_res == JNI_EDETACHED) {
12210                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12211         }
12212 }
12213 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
12214         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12215         JNIEnv *env;
12216         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12217         if (get_jenv_res == JNI_EDETACHED) {
12218                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12219         } else {
12220                 DO_ASSERT(get_jenv_res == JNI_OK);
12221         }
12222         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12223         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12224         LDKChannelUpdate msg_var = *msg;
12225         int64_t msg_ref = 0;
12226         msg_var = ChannelUpdate_clone(&msg_var);
12227         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12228         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12229         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12230         CHECK(obj != NULL);
12231         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
12232         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12233                 (*env)->ExceptionDescribe(env);
12234                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
12235         }
12236         if (get_jenv_res == JNI_EDETACHED) {
12237                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12238         }
12239 }
12240 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
12241         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12242         JNIEnv *env;
12243         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12244         if (get_jenv_res == JNI_EDETACHED) {
12245                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12246         } else {
12247                 DO_ASSERT(get_jenv_res == JNI_OK);
12248         }
12249         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12250         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12251         LDKErrorMessage msg_var = *msg;
12252         int64_t msg_ref = 0;
12253         msg_var = ErrorMessage_clone(&msg_var);
12254         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12255         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12256         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12257         CHECK(obj != NULL);
12258         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
12259         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12260                 (*env)->ExceptionDescribe(env);
12261                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
12262         }
12263         if (get_jenv_res == JNI_EDETACHED) {
12264                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12265         }
12266 }
12267 LDKNodeFeatures provided_node_features_LDKChannelMessageHandler_jcall(const void* this_arg) {
12268         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12269         JNIEnv *env;
12270         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12271         if (get_jenv_res == JNI_EDETACHED) {
12272                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12273         } else {
12274                 DO_ASSERT(get_jenv_res == JNI_OK);
12275         }
12276         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12277         CHECK(obj != NULL);
12278         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
12279         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12280                 (*env)->ExceptionDescribe(env);
12281                 (*env)->FatalError(env, "A call to provided_node_features in LDKChannelMessageHandler from rust threw an exception.");
12282         }
12283         LDKNodeFeatures ret_conv;
12284         ret_conv.inner = untag_ptr(ret);
12285         ret_conv.is_owned = ptr_is_owned(ret);
12286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
12287         if (get_jenv_res == JNI_EDETACHED) {
12288                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12289         }
12290         return ret_conv;
12291 }
12292 LDKInitFeatures provided_init_features_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
12293         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12294         JNIEnv *env;
12295         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12296         if (get_jenv_res == JNI_EDETACHED) {
12297                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12298         } else {
12299                 DO_ASSERT(get_jenv_res == JNI_OK);
12300         }
12301         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12302         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12303         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12304         CHECK(obj != NULL);
12305         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
12306         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12307                 (*env)->ExceptionDescribe(env);
12308                 (*env)->FatalError(env, "A call to provided_init_features in LDKChannelMessageHandler from rust threw an exception.");
12309         }
12310         LDKInitFeatures ret_conv;
12311         ret_conv.inner = untag_ptr(ret);
12312         ret_conv.is_owned = ptr_is_owned(ret);
12313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
12314         if (get_jenv_res == JNI_EDETACHED) {
12315                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12316         }
12317         return ret_conv;
12318 }
12319 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
12320         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
12321         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12322         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
12323 }
12324 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12325         jclass c = (*env)->GetObjectClass(env, o);
12326         CHECK(c != NULL);
12327         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
12328         atomic_init(&calls->refcnt, 1);
12329         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12330         calls->o = (*env)->NewWeakGlobalRef(env, o);
12331         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
12332         CHECK(calls->handle_open_channel_meth != NULL);
12333         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
12334         CHECK(calls->handle_accept_channel_meth != NULL);
12335         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
12336         CHECK(calls->handle_funding_created_meth != NULL);
12337         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
12338         CHECK(calls->handle_funding_signed_meth != NULL);
12339         calls->handle_channel_ready_meth = (*env)->GetMethodID(env, c, "handle_channel_ready", "([BJ)V");
12340         CHECK(calls->handle_channel_ready_meth != NULL);
12341         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
12342         CHECK(calls->handle_shutdown_meth != NULL);
12343         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
12344         CHECK(calls->handle_closing_signed_meth != NULL);
12345         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
12346         CHECK(calls->handle_update_add_htlc_meth != NULL);
12347         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
12348         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
12349         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
12350         CHECK(calls->handle_update_fail_htlc_meth != NULL);
12351         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
12352         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
12353         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
12354         CHECK(calls->handle_commitment_signed_meth != NULL);
12355         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
12356         CHECK(calls->handle_revoke_and_ack_meth != NULL);
12357         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
12358         CHECK(calls->handle_update_fee_meth != NULL);
12359         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
12360         CHECK(calls->handle_announcement_signatures_meth != NULL);
12361         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
12362         CHECK(calls->peer_disconnected_meth != NULL);
12363         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
12364         CHECK(calls->peer_connected_meth != NULL);
12365         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
12366         CHECK(calls->handle_channel_reestablish_meth != NULL);
12367         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
12368         CHECK(calls->handle_channel_update_meth != NULL);
12369         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
12370         CHECK(calls->handle_error_meth != NULL);
12371         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
12372         CHECK(calls->provided_node_features_meth != NULL);
12373         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
12374         CHECK(calls->provided_init_features_meth != NULL);
12375
12376         LDKChannelMessageHandler ret = {
12377                 .this_arg = (void*) calls,
12378                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
12379                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
12380                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
12381                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
12382                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
12383                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
12384                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
12385                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
12386                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
12387                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
12388                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
12389                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
12390                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
12391                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
12392                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
12393                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
12394                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
12395                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
12396                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
12397                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
12398                 .provided_node_features = provided_node_features_LDKChannelMessageHandler_jcall,
12399                 .provided_init_features = provided_init_features_LDKChannelMessageHandler_jcall,
12400                 .free = LDKChannelMessageHandler_JCalls_free,
12401                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
12402         };
12403         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
12404         return ret;
12405 }
12406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12407         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
12408         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
12409         return tag_ptr(res_ptr, true);
12410 }
12411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
12412         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)untag_ptr(arg);
12413         return tag_ptr(&inp->MessageSendEventsProvider, false);
12414 }
12415 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) {
12416         void* this_arg_ptr = untag_ptr(this_arg);
12417         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12418         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12419         LDKPublicKey their_node_id_ref;
12420         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12421         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12422         LDKInitFeatures their_features_conv;
12423         their_features_conv.inner = untag_ptr(their_features);
12424         their_features_conv.is_owned = ptr_is_owned(their_features);
12425         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12426         their_features_conv = InitFeatures_clone(&their_features_conv);
12427         LDKOpenChannel msg_conv;
12428         msg_conv.inner = untag_ptr(msg);
12429         msg_conv.is_owned = ptr_is_owned(msg);
12430         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12431         msg_conv.is_owned = false;
12432         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
12433 }
12434
12435 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) {
12436         void* this_arg_ptr = untag_ptr(this_arg);
12437         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12438         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12439         LDKPublicKey their_node_id_ref;
12440         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12441         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12442         LDKInitFeatures their_features_conv;
12443         their_features_conv.inner = untag_ptr(their_features);
12444         their_features_conv.is_owned = ptr_is_owned(their_features);
12445         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12446         their_features_conv = InitFeatures_clone(&their_features_conv);
12447         LDKAcceptChannel msg_conv;
12448         msg_conv.inner = untag_ptr(msg);
12449         msg_conv.is_owned = ptr_is_owned(msg);
12450         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12451         msg_conv.is_owned = false;
12452         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
12453 }
12454
12455 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) {
12456         void* this_arg_ptr = untag_ptr(this_arg);
12457         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12458         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12459         LDKPublicKey their_node_id_ref;
12460         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12461         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12462         LDKFundingCreated msg_conv;
12463         msg_conv.inner = untag_ptr(msg);
12464         msg_conv.is_owned = ptr_is_owned(msg);
12465         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12466         msg_conv.is_owned = false;
12467         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12468 }
12469
12470 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) {
12471         void* this_arg_ptr = untag_ptr(this_arg);
12472         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12473         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12474         LDKPublicKey their_node_id_ref;
12475         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12476         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12477         LDKFundingSigned msg_conv;
12478         msg_conv.inner = untag_ptr(msg);
12479         msg_conv.is_owned = ptr_is_owned(msg);
12480         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12481         msg_conv.is_owned = false;
12482         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12483 }
12484
12485 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
12486         void* this_arg_ptr = untag_ptr(this_arg);
12487         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12488         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12489         LDKPublicKey their_node_id_ref;
12490         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12491         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12492         LDKChannelReady msg_conv;
12493         msg_conv.inner = untag_ptr(msg);
12494         msg_conv.is_owned = ptr_is_owned(msg);
12495         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12496         msg_conv.is_owned = false;
12497         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12498 }
12499
12500 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) {
12501         void* this_arg_ptr = untag_ptr(this_arg);
12502         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12503         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12504         LDKPublicKey their_node_id_ref;
12505         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12506         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12507         LDKInitFeatures their_features_conv;
12508         their_features_conv.inner = untag_ptr(their_features);
12509         their_features_conv.is_owned = ptr_is_owned(their_features);
12510         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12511         their_features_conv.is_owned = false;
12512         LDKShutdown msg_conv;
12513         msg_conv.inner = untag_ptr(msg);
12514         msg_conv.is_owned = ptr_is_owned(msg);
12515         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12516         msg_conv.is_owned = false;
12517         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
12518 }
12519
12520 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) {
12521         void* this_arg_ptr = untag_ptr(this_arg);
12522         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12523         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12524         LDKPublicKey their_node_id_ref;
12525         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12526         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12527         LDKClosingSigned msg_conv;
12528         msg_conv.inner = untag_ptr(msg);
12529         msg_conv.is_owned = ptr_is_owned(msg);
12530         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12531         msg_conv.is_owned = false;
12532         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12533 }
12534
12535 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) {
12536         void* this_arg_ptr = untag_ptr(this_arg);
12537         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12538         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12539         LDKPublicKey their_node_id_ref;
12540         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12541         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12542         LDKUpdateAddHTLC msg_conv;
12543         msg_conv.inner = untag_ptr(msg);
12544         msg_conv.is_owned = ptr_is_owned(msg);
12545         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12546         msg_conv.is_owned = false;
12547         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12548 }
12549
12550 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) {
12551         void* this_arg_ptr = untag_ptr(this_arg);
12552         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12553         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12554         LDKPublicKey their_node_id_ref;
12555         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12556         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12557         LDKUpdateFulfillHTLC msg_conv;
12558         msg_conv.inner = untag_ptr(msg);
12559         msg_conv.is_owned = ptr_is_owned(msg);
12560         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12561         msg_conv.is_owned = false;
12562         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12563 }
12564
12565 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) {
12566         void* this_arg_ptr = untag_ptr(this_arg);
12567         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12568         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12569         LDKPublicKey their_node_id_ref;
12570         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12571         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12572         LDKUpdateFailHTLC msg_conv;
12573         msg_conv.inner = untag_ptr(msg);
12574         msg_conv.is_owned = ptr_is_owned(msg);
12575         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12576         msg_conv.is_owned = false;
12577         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12578 }
12579
12580 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) {
12581         void* this_arg_ptr = untag_ptr(this_arg);
12582         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12583         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12584         LDKPublicKey their_node_id_ref;
12585         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12586         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12587         LDKUpdateFailMalformedHTLC msg_conv;
12588         msg_conv.inner = untag_ptr(msg);
12589         msg_conv.is_owned = ptr_is_owned(msg);
12590         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12591         msg_conv.is_owned = false;
12592         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12593 }
12594
12595 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) {
12596         void* this_arg_ptr = untag_ptr(this_arg);
12597         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12598         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12599         LDKPublicKey their_node_id_ref;
12600         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12601         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12602         LDKCommitmentSigned msg_conv;
12603         msg_conv.inner = untag_ptr(msg);
12604         msg_conv.is_owned = ptr_is_owned(msg);
12605         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12606         msg_conv.is_owned = false;
12607         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12608 }
12609
12610 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) {
12611         void* this_arg_ptr = untag_ptr(this_arg);
12612         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12613         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12614         LDKPublicKey their_node_id_ref;
12615         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12616         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12617         LDKRevokeAndACK msg_conv;
12618         msg_conv.inner = untag_ptr(msg);
12619         msg_conv.is_owned = ptr_is_owned(msg);
12620         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12621         msg_conv.is_owned = false;
12622         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12623 }
12624
12625 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) {
12626         void* this_arg_ptr = untag_ptr(this_arg);
12627         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12628         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12629         LDKPublicKey their_node_id_ref;
12630         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12631         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12632         LDKUpdateFee msg_conv;
12633         msg_conv.inner = untag_ptr(msg);
12634         msg_conv.is_owned = ptr_is_owned(msg);
12635         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12636         msg_conv.is_owned = false;
12637         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12638 }
12639
12640 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) {
12641         void* this_arg_ptr = untag_ptr(this_arg);
12642         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12643         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12644         LDKPublicKey their_node_id_ref;
12645         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12646         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12647         LDKAnnouncementSignatures msg_conv;
12648         msg_conv.inner = untag_ptr(msg);
12649         msg_conv.is_owned = ptr_is_owned(msg);
12650         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12651         msg_conv.is_owned = false;
12652         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12653 }
12654
12655 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) {
12656         void* this_arg_ptr = untag_ptr(this_arg);
12657         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12658         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12659         LDKPublicKey their_node_id_ref;
12660         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12661         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12662         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
12663 }
12664
12665 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) {
12666         void* this_arg_ptr = untag_ptr(this_arg);
12667         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12668         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12669         LDKPublicKey their_node_id_ref;
12670         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12671         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12672         LDKInit msg_conv;
12673         msg_conv.inner = untag_ptr(msg);
12674         msg_conv.is_owned = ptr_is_owned(msg);
12675         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12676         msg_conv.is_owned = false;
12677         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12678 }
12679
12680 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) {
12681         void* this_arg_ptr = untag_ptr(this_arg);
12682         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12683         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12684         LDKPublicKey their_node_id_ref;
12685         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12686         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12687         LDKChannelReestablish msg_conv;
12688         msg_conv.inner = untag_ptr(msg);
12689         msg_conv.is_owned = ptr_is_owned(msg);
12690         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12691         msg_conv.is_owned = false;
12692         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12693 }
12694
12695 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) {
12696         void* this_arg_ptr = untag_ptr(this_arg);
12697         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12698         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12699         LDKPublicKey their_node_id_ref;
12700         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12701         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12702         LDKChannelUpdate msg_conv;
12703         msg_conv.inner = untag_ptr(msg);
12704         msg_conv.is_owned = ptr_is_owned(msg);
12705         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12706         msg_conv.is_owned = false;
12707         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12708 }
12709
12710 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) {
12711         void* this_arg_ptr = untag_ptr(this_arg);
12712         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12713         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12714         LDKPublicKey their_node_id_ref;
12715         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12716         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12717         LDKErrorMessage msg_conv;
12718         msg_conv.inner = untag_ptr(msg);
12719         msg_conv.is_owned = ptr_is_owned(msg);
12720         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12721         msg_conv.is_owned = false;
12722         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12723 }
12724
12725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
12726         void* this_arg_ptr = untag_ptr(this_arg);
12727         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12728         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12729         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
12730         int64_t ret_ref = 0;
12731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
12732         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
12733         return ret_ref;
12734 }
12735
12736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1provided_1init_1features(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id) {
12737         void* this_arg_ptr = untag_ptr(this_arg);
12738         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12739         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12740         LDKPublicKey their_node_id_ref;
12741         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12742         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12743         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
12744         int64_t ret_ref = 0;
12745         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
12746         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
12747         return ret_ref;
12748 }
12749
12750 typedef struct LDKRoutingMessageHandler_JCalls {
12751         atomic_size_t refcnt;
12752         JavaVM *vm;
12753         jweak o;
12754         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
12755         jmethodID handle_node_announcement_meth;
12756         jmethodID handle_channel_announcement_meth;
12757         jmethodID handle_channel_update_meth;
12758         jmethodID get_next_channel_announcement_meth;
12759         jmethodID get_next_node_announcement_meth;
12760         jmethodID peer_connected_meth;
12761         jmethodID handle_reply_channel_range_meth;
12762         jmethodID handle_reply_short_channel_ids_end_meth;
12763         jmethodID handle_query_channel_range_meth;
12764         jmethodID handle_query_short_channel_ids_meth;
12765         jmethodID provided_node_features_meth;
12766         jmethodID provided_init_features_meth;
12767 } LDKRoutingMessageHandler_JCalls;
12768 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
12769         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12770         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12771                 JNIEnv *env;
12772                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12773                 if (get_jenv_res == JNI_EDETACHED) {
12774                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12775                 } else {
12776                         DO_ASSERT(get_jenv_res == JNI_OK);
12777                 }
12778                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12779                 if (get_jenv_res == JNI_EDETACHED) {
12780                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12781                 }
12782                 FREE(j_calls);
12783         }
12784 }
12785 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
12786         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12787         JNIEnv *env;
12788         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12789         if (get_jenv_res == JNI_EDETACHED) {
12790                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12791         } else {
12792                 DO_ASSERT(get_jenv_res == JNI_OK);
12793         }
12794         LDKNodeAnnouncement msg_var = *msg;
12795         int64_t msg_ref = 0;
12796         msg_var = NodeAnnouncement_clone(&msg_var);
12797         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12798         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12799         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12800         CHECK(obj != NULL);
12801         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
12802         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12803                 (*env)->ExceptionDescribe(env);
12804                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
12805         }
12806         void* ret_ptr = untag_ptr(ret);
12807         CHECK_ACCESS(ret_ptr);
12808         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
12809         FREE(untag_ptr(ret));
12810         if (get_jenv_res == JNI_EDETACHED) {
12811                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12812         }
12813         return ret_conv;
12814 }
12815 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
12816         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12817         JNIEnv *env;
12818         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12819         if (get_jenv_res == JNI_EDETACHED) {
12820                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12821         } else {
12822                 DO_ASSERT(get_jenv_res == JNI_OK);
12823         }
12824         LDKChannelAnnouncement msg_var = *msg;
12825         int64_t msg_ref = 0;
12826         msg_var = ChannelAnnouncement_clone(&msg_var);
12827         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12828         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12829         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12830         CHECK(obj != NULL);
12831         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
12832         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12833                 (*env)->ExceptionDescribe(env);
12834                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
12835         }
12836         void* ret_ptr = untag_ptr(ret);
12837         CHECK_ACCESS(ret_ptr);
12838         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
12839         FREE(untag_ptr(ret));
12840         if (get_jenv_res == JNI_EDETACHED) {
12841                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12842         }
12843         return ret_conv;
12844 }
12845 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
12846         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12847         JNIEnv *env;
12848         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12849         if (get_jenv_res == JNI_EDETACHED) {
12850                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12851         } else {
12852                 DO_ASSERT(get_jenv_res == JNI_OK);
12853         }
12854         LDKChannelUpdate msg_var = *msg;
12855         int64_t msg_ref = 0;
12856         msg_var = ChannelUpdate_clone(&msg_var);
12857         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12858         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12859         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12860         CHECK(obj != NULL);
12861         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
12862         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12863                 (*env)->ExceptionDescribe(env);
12864                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
12865         }
12866         void* ret_ptr = untag_ptr(ret);
12867         CHECK_ACCESS(ret_ptr);
12868         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
12869         FREE(untag_ptr(ret));
12870         if (get_jenv_res == JNI_EDETACHED) {
12871                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12872         }
12873         return ret_conv;
12874 }
12875 LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point) {
12876         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12877         JNIEnv *env;
12878         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12879         if (get_jenv_res == JNI_EDETACHED) {
12880                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12881         } else {
12882                 DO_ASSERT(get_jenv_res == JNI_OK);
12883         }
12884         int64_t starting_point_conv = starting_point;
12885         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12886         CHECK(obj != NULL);
12887         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_next_channel_announcement_meth, starting_point_conv);
12888         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12889                 (*env)->ExceptionDescribe(env);
12890                 (*env)->FatalError(env, "A call to get_next_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
12891         }
12892         void* ret_ptr = untag_ptr(ret);
12893         CHECK_ACCESS(ret_ptr);
12894         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_conv = *(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(ret_ptr);
12895         FREE(untag_ptr(ret));
12896         if (get_jenv_res == JNI_EDETACHED) {
12897                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12898         }
12899         return ret_conv;
12900 }
12901 LDKNodeAnnouncement get_next_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point) {
12902         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12903         JNIEnv *env;
12904         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12905         if (get_jenv_res == JNI_EDETACHED) {
12906                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12907         } else {
12908                 DO_ASSERT(get_jenv_res == JNI_OK);
12909         }
12910         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
12911         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
12912         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12913         CHECK(obj != NULL);
12914         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_next_node_announcement_meth, starting_point_arr);
12915         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12916                 (*env)->ExceptionDescribe(env);
12917                 (*env)->FatalError(env, "A call to get_next_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
12918         }
12919         LDKNodeAnnouncement ret_conv;
12920         ret_conv.inner = untag_ptr(ret);
12921         ret_conv.is_owned = ptr_is_owned(ret);
12922         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
12923         if (get_jenv_res == JNI_EDETACHED) {
12924                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12925         }
12926         return ret_conv;
12927 }
12928 void peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
12929         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12930         JNIEnv *env;
12931         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12932         if (get_jenv_res == JNI_EDETACHED) {
12933                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12934         } else {
12935                 DO_ASSERT(get_jenv_res == JNI_OK);
12936         }
12937         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12938         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12939         LDKInit init_var = *init;
12940         int64_t init_ref = 0;
12941         init_var = Init_clone(&init_var);
12942         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
12943         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
12944         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12945         CHECK(obj != NULL);
12946         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref);
12947         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12948                 (*env)->ExceptionDescribe(env);
12949                 (*env)->FatalError(env, "A call to peer_connected in LDKRoutingMessageHandler from rust threw an exception.");
12950         }
12951         if (get_jenv_res == JNI_EDETACHED) {
12952                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12953         }
12954 }
12955 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
12956         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12957         JNIEnv *env;
12958         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12959         if (get_jenv_res == JNI_EDETACHED) {
12960                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12961         } else {
12962                 DO_ASSERT(get_jenv_res == JNI_OK);
12963         }
12964         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12965         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12966         LDKReplyChannelRange msg_var = msg;
12967         int64_t msg_ref = 0;
12968         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12969         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12970         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12971         CHECK(obj != NULL);
12972         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
12973         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12974                 (*env)->ExceptionDescribe(env);
12975                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
12976         }
12977         void* ret_ptr = untag_ptr(ret);
12978         CHECK_ACCESS(ret_ptr);
12979         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
12980         FREE(untag_ptr(ret));
12981         if (get_jenv_res == JNI_EDETACHED) {
12982                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12983         }
12984         return ret_conv;
12985 }
12986 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
12987         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
12988         JNIEnv *env;
12989         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12990         if (get_jenv_res == JNI_EDETACHED) {
12991                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12992         } else {
12993                 DO_ASSERT(get_jenv_res == JNI_OK);
12994         }
12995         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12996         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12997         LDKReplyShortChannelIdsEnd msg_var = msg;
12998         int64_t msg_ref = 0;
12999         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13000         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13001         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13002         CHECK(obj != NULL);
13003         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
13004         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13005                 (*env)->ExceptionDescribe(env);
13006                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
13007         }
13008         void* ret_ptr = untag_ptr(ret);
13009         CHECK_ACCESS(ret_ptr);
13010         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13011         FREE(untag_ptr(ret));
13012         if (get_jenv_res == JNI_EDETACHED) {
13013                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13014         }
13015         return ret_conv;
13016 }
13017 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
13018         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13019         JNIEnv *env;
13020         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13021         if (get_jenv_res == JNI_EDETACHED) {
13022                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13023         } else {
13024                 DO_ASSERT(get_jenv_res == JNI_OK);
13025         }
13026         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13027         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13028         LDKQueryChannelRange msg_var = msg;
13029         int64_t msg_ref = 0;
13030         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13031         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13032         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13033         CHECK(obj != NULL);
13034         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
13035         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13036                 (*env)->ExceptionDescribe(env);
13037                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
13038         }
13039         void* ret_ptr = untag_ptr(ret);
13040         CHECK_ACCESS(ret_ptr);
13041         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13042         FREE(untag_ptr(ret));
13043         if (get_jenv_res == JNI_EDETACHED) {
13044                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13045         }
13046         return ret_conv;
13047 }
13048 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
13049         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13050         JNIEnv *env;
13051         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13052         if (get_jenv_res == JNI_EDETACHED) {
13053                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13054         } else {
13055                 DO_ASSERT(get_jenv_res == JNI_OK);
13056         }
13057         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13058         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13059         LDKQueryShortChannelIds msg_var = msg;
13060         int64_t msg_ref = 0;
13061         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13062         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13063         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13064         CHECK(obj != NULL);
13065         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
13066         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13067                 (*env)->ExceptionDescribe(env);
13068                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
13069         }
13070         void* ret_ptr = untag_ptr(ret);
13071         CHECK_ACCESS(ret_ptr);
13072         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13073         FREE(untag_ptr(ret));
13074         if (get_jenv_res == JNI_EDETACHED) {
13075                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13076         }
13077         return ret_conv;
13078 }
13079 LDKNodeFeatures provided_node_features_LDKRoutingMessageHandler_jcall(const void* this_arg) {
13080         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13081         JNIEnv *env;
13082         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13083         if (get_jenv_res == JNI_EDETACHED) {
13084                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13085         } else {
13086                 DO_ASSERT(get_jenv_res == JNI_OK);
13087         }
13088         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13089         CHECK(obj != NULL);
13090         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
13091         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13092                 (*env)->ExceptionDescribe(env);
13093                 (*env)->FatalError(env, "A call to provided_node_features in LDKRoutingMessageHandler from rust threw an exception.");
13094         }
13095         LDKNodeFeatures ret_conv;
13096         ret_conv.inner = untag_ptr(ret);
13097         ret_conv.is_owned = ptr_is_owned(ret);
13098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13099         if (get_jenv_res == JNI_EDETACHED) {
13100                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13101         }
13102         return ret_conv;
13103 }
13104 LDKInitFeatures provided_init_features_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
13105         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13106         JNIEnv *env;
13107         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13108         if (get_jenv_res == JNI_EDETACHED) {
13109                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13110         } else {
13111                 DO_ASSERT(get_jenv_res == JNI_OK);
13112         }
13113         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13114         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13115         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13116         CHECK(obj != NULL);
13117         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
13118         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13119                 (*env)->ExceptionDescribe(env);
13120                 (*env)->FatalError(env, "A call to provided_init_features in LDKRoutingMessageHandler from rust threw an exception.");
13121         }
13122         LDKInitFeatures ret_conv;
13123         ret_conv.inner = untag_ptr(ret);
13124         ret_conv.is_owned = ptr_is_owned(ret);
13125         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13126         if (get_jenv_res == JNI_EDETACHED) {
13127                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13128         }
13129         return ret_conv;
13130 }
13131 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
13132         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
13133         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13134         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
13135 }
13136 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13137         jclass c = (*env)->GetObjectClass(env, o);
13138         CHECK(c != NULL);
13139         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
13140         atomic_init(&calls->refcnt, 1);
13141         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13142         calls->o = (*env)->NewWeakGlobalRef(env, o);
13143         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
13144         CHECK(calls->handle_node_announcement_meth != NULL);
13145         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
13146         CHECK(calls->handle_channel_announcement_meth != NULL);
13147         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
13148         CHECK(calls->handle_channel_update_meth != NULL);
13149         calls->get_next_channel_announcement_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcement", "(J)J");
13150         CHECK(calls->get_next_channel_announcement_meth != NULL);
13151         calls->get_next_node_announcement_meth = (*env)->GetMethodID(env, c, "get_next_node_announcement", "([B)J");
13152         CHECK(calls->get_next_node_announcement_meth != NULL);
13153         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
13154         CHECK(calls->peer_connected_meth != NULL);
13155         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
13156         CHECK(calls->handle_reply_channel_range_meth != NULL);
13157         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
13158         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
13159         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
13160         CHECK(calls->handle_query_channel_range_meth != NULL);
13161         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
13162         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
13163         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
13164         CHECK(calls->provided_node_features_meth != NULL);
13165         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
13166         CHECK(calls->provided_init_features_meth != NULL);
13167
13168         LDKRoutingMessageHandler ret = {
13169                 .this_arg = (void*) calls,
13170                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
13171                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
13172                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
13173                 .get_next_channel_announcement = get_next_channel_announcement_LDKRoutingMessageHandler_jcall,
13174                 .get_next_node_announcement = get_next_node_announcement_LDKRoutingMessageHandler_jcall,
13175                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
13176                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
13177                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
13178                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
13179                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
13180                 .provided_node_features = provided_node_features_LDKRoutingMessageHandler_jcall,
13181                 .provided_init_features = provided_init_features_LDKRoutingMessageHandler_jcall,
13182                 .free = LDKRoutingMessageHandler_JCalls_free,
13183                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
13184         };
13185         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
13186         return ret;
13187 }
13188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13189         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
13190         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
13191         return tag_ptr(res_ptr, true);
13192 }
13193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
13194         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)untag_ptr(arg);
13195         return tag_ptr(&inp->MessageSendEventsProvider, false);
13196 }
13197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13198         void* this_arg_ptr = untag_ptr(this_arg);
13199         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13200         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13201         LDKNodeAnnouncement msg_conv;
13202         msg_conv.inner = untag_ptr(msg);
13203         msg_conv.is_owned = ptr_is_owned(msg);
13204         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13205         msg_conv.is_owned = false;
13206         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13207         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
13208         return tag_ptr(ret_conv, true);
13209 }
13210
13211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13212         void* this_arg_ptr = untag_ptr(this_arg);
13213         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13214         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13215         LDKChannelAnnouncement msg_conv;
13216         msg_conv.inner = untag_ptr(msg);
13217         msg_conv.is_owned = ptr_is_owned(msg);
13218         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13219         msg_conv.is_owned = false;
13220         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13221         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
13222         return tag_ptr(ret_conv, true);
13223 }
13224
13225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13226         void* this_arg_ptr = untag_ptr(this_arg);
13227         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13228         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13229         LDKChannelUpdate msg_conv;
13230         msg_conv.inner = untag_ptr(msg);
13231         msg_conv.is_owned = ptr_is_owned(msg);
13232         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13233         msg_conv.is_owned = false;
13234         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13235         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
13236         return tag_ptr(ret_conv, true);
13237 }
13238
13239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t starting_point) {
13240         void* this_arg_ptr = untag_ptr(this_arg);
13241         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13242         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13243         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
13244         *ret_copy = (this_arg_conv->get_next_channel_announcement)(this_arg_conv->this_arg, starting_point);
13245         int64_t ret_ref = tag_ptr(ret_copy, true);
13246         return ret_ref;
13247 }
13248
13249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray starting_point) {
13250         void* this_arg_ptr = untag_ptr(this_arg);
13251         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13252         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13253         LDKPublicKey starting_point_ref;
13254         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
13255         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
13256         LDKNodeAnnouncement ret_var = (this_arg_conv->get_next_node_announcement)(this_arg_conv->this_arg, starting_point_ref);
13257         int64_t ret_ref = 0;
13258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13259         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13260         return ret_ref;
13261 }
13262
13263 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1peer_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t init) {
13264         void* this_arg_ptr = untag_ptr(this_arg);
13265         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13266         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13267         LDKPublicKey their_node_id_ref;
13268         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13269         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13270         LDKInit init_conv;
13271         init_conv.inner = untag_ptr(init);
13272         init_conv.is_owned = ptr_is_owned(init);
13273         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
13274         init_conv.is_owned = false;
13275         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
13276 }
13277
13278 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) {
13279         void* this_arg_ptr = untag_ptr(this_arg);
13280         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13281         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13282         LDKPublicKey their_node_id_ref;
13283         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13284         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13285         LDKReplyChannelRange msg_conv;
13286         msg_conv.inner = untag_ptr(msg);
13287         msg_conv.is_owned = ptr_is_owned(msg);
13288         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13289         msg_conv = ReplyChannelRange_clone(&msg_conv);
13290         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13291         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13292         return tag_ptr(ret_conv, true);
13293 }
13294
13295 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) {
13296         void* this_arg_ptr = untag_ptr(this_arg);
13297         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13298         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13299         LDKPublicKey their_node_id_ref;
13300         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13301         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13302         LDKReplyShortChannelIdsEnd msg_conv;
13303         msg_conv.inner = untag_ptr(msg);
13304         msg_conv.is_owned = ptr_is_owned(msg);
13305         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13306         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
13307         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13308         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13309         return tag_ptr(ret_conv, true);
13310 }
13311
13312 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) {
13313         void* this_arg_ptr = untag_ptr(this_arg);
13314         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13315         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13316         LDKPublicKey their_node_id_ref;
13317         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13318         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13319         LDKQueryChannelRange msg_conv;
13320         msg_conv.inner = untag_ptr(msg);
13321         msg_conv.is_owned = ptr_is_owned(msg);
13322         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13323         msg_conv = QueryChannelRange_clone(&msg_conv);
13324         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13325         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13326         return tag_ptr(ret_conv, true);
13327 }
13328
13329 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) {
13330         void* this_arg_ptr = untag_ptr(this_arg);
13331         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13332         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13333         LDKPublicKey their_node_id_ref;
13334         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13335         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13336         LDKQueryShortChannelIds msg_conv;
13337         msg_conv.inner = untag_ptr(msg);
13338         msg_conv.is_owned = ptr_is_owned(msg);
13339         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13340         msg_conv = QueryShortChannelIds_clone(&msg_conv);
13341         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13342         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13343         return tag_ptr(ret_conv, true);
13344 }
13345
13346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
13347         void* this_arg_ptr = untag_ptr(this_arg);
13348         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13349         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13350         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
13351         int64_t ret_ref = 0;
13352         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13353         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13354         return ret_ref;
13355 }
13356
13357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1provided_1init_1features(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id) {
13358         void* this_arg_ptr = untag_ptr(this_arg);
13359         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13360         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13361         LDKPublicKey their_node_id_ref;
13362         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13363         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13364         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
13365         int64_t ret_ref = 0;
13366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13367         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13368         return ret_ref;
13369 }
13370
13371 typedef struct LDKOnionMessageHandler_JCalls {
13372         atomic_size_t refcnt;
13373         JavaVM *vm;
13374         jweak o;
13375         LDKOnionMessageProvider_JCalls* OnionMessageProvider;
13376         jmethodID handle_onion_message_meth;
13377         jmethodID peer_connected_meth;
13378         jmethodID peer_disconnected_meth;
13379         jmethodID provided_node_features_meth;
13380         jmethodID provided_init_features_meth;
13381 } LDKOnionMessageHandler_JCalls;
13382 static void LDKOnionMessageHandler_JCalls_free(void* this_arg) {
13383         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13384         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13385                 JNIEnv *env;
13386                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13387                 if (get_jenv_res == JNI_EDETACHED) {
13388                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13389                 } else {
13390                         DO_ASSERT(get_jenv_res == JNI_OK);
13391                 }
13392                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13393                 if (get_jenv_res == JNI_EDETACHED) {
13394                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13395                 }
13396                 FREE(j_calls);
13397         }
13398 }
13399 void handle_onion_message_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey peer_node_id, const LDKOnionMessage * msg) {
13400         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13401         JNIEnv *env;
13402         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13403         if (get_jenv_res == JNI_EDETACHED) {
13404                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13405         } else {
13406                 DO_ASSERT(get_jenv_res == JNI_OK);
13407         }
13408         int8_tArray peer_node_id_arr = (*env)->NewByteArray(env, 33);
13409         (*env)->SetByteArrayRegion(env, peer_node_id_arr, 0, 33, peer_node_id.compressed_form);
13410         LDKOnionMessage msg_var = *msg;
13411         int64_t msg_ref = 0;
13412         msg_var = OnionMessage_clone(&msg_var);
13413         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13414         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13415         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13416         CHECK(obj != NULL);
13417         (*env)->CallVoidMethod(env, obj, j_calls->handle_onion_message_meth, peer_node_id_arr, msg_ref);
13418         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13419                 (*env)->ExceptionDescribe(env);
13420                 (*env)->FatalError(env, "A call to handle_onion_message in LDKOnionMessageHandler from rust threw an exception.");
13421         }
13422         if (get_jenv_res == JNI_EDETACHED) {
13423                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13424         }
13425 }
13426 void peer_connected_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
13427         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13428         JNIEnv *env;
13429         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13430         if (get_jenv_res == JNI_EDETACHED) {
13431                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13432         } else {
13433                 DO_ASSERT(get_jenv_res == JNI_OK);
13434         }
13435         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13436         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13437         LDKInit init_var = *init;
13438         int64_t init_ref = 0;
13439         init_var = Init_clone(&init_var);
13440         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
13441         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
13442         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13443         CHECK(obj != NULL);
13444         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref);
13445         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13446                 (*env)->ExceptionDescribe(env);
13447                 (*env)->FatalError(env, "A call to peer_connected in LDKOnionMessageHandler from rust threw an exception.");
13448         }
13449         if (get_jenv_res == JNI_EDETACHED) {
13450                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13451         }
13452 }
13453 void peer_disconnected_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
13454         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
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         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13463         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13464         jboolean no_connection_possible_conv = no_connection_possible;
13465         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13466         CHECK(obj != NULL);
13467         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible_conv);
13468         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13469                 (*env)->ExceptionDescribe(env);
13470                 (*env)->FatalError(env, "A call to peer_disconnected in LDKOnionMessageHandler from rust threw an exception.");
13471         }
13472         if (get_jenv_res == JNI_EDETACHED) {
13473                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13474         }
13475 }
13476 LDKNodeFeatures provided_node_features_LDKOnionMessageHandler_jcall(const void* this_arg) {
13477         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13478         JNIEnv *env;
13479         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13480         if (get_jenv_res == JNI_EDETACHED) {
13481                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13482         } else {
13483                 DO_ASSERT(get_jenv_res == JNI_OK);
13484         }
13485         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13486         CHECK(obj != NULL);
13487         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
13488         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13489                 (*env)->ExceptionDescribe(env);
13490                 (*env)->FatalError(env, "A call to provided_node_features in LDKOnionMessageHandler from rust threw an exception.");
13491         }
13492         LDKNodeFeatures ret_conv;
13493         ret_conv.inner = untag_ptr(ret);
13494         ret_conv.is_owned = ptr_is_owned(ret);
13495         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13496         if (get_jenv_res == JNI_EDETACHED) {
13497                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13498         }
13499         return ret_conv;
13500 }
13501 LDKInitFeatures provided_init_features_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
13502         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13503         JNIEnv *env;
13504         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13505         if (get_jenv_res == JNI_EDETACHED) {
13506                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13507         } else {
13508                 DO_ASSERT(get_jenv_res == JNI_OK);
13509         }
13510         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13511         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13512         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13513         CHECK(obj != NULL);
13514         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
13515         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13516                 (*env)->ExceptionDescribe(env);
13517                 (*env)->FatalError(env, "A call to provided_init_features in LDKOnionMessageHandler from rust threw an exception.");
13518         }
13519         LDKInitFeatures ret_conv;
13520         ret_conv.inner = untag_ptr(ret);
13521         ret_conv.is_owned = ptr_is_owned(ret);
13522         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13523         if (get_jenv_res == JNI_EDETACHED) {
13524                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13525         }
13526         return ret_conv;
13527 }
13528 static void LDKOnionMessageHandler_JCalls_cloned(LDKOnionMessageHandler* new_obj) {
13529         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) new_obj->this_arg;
13530         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13531         atomic_fetch_add_explicit(&j_calls->OnionMessageProvider->refcnt, 1, memory_order_release);
13532 }
13533 static inline LDKOnionMessageHandler LDKOnionMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject OnionMessageProvider) {
13534         jclass c = (*env)->GetObjectClass(env, o);
13535         CHECK(c != NULL);
13536         LDKOnionMessageHandler_JCalls *calls = MALLOC(sizeof(LDKOnionMessageHandler_JCalls), "LDKOnionMessageHandler_JCalls");
13537         atomic_init(&calls->refcnt, 1);
13538         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13539         calls->o = (*env)->NewWeakGlobalRef(env, o);
13540         calls->handle_onion_message_meth = (*env)->GetMethodID(env, c, "handle_onion_message", "([BJ)V");
13541         CHECK(calls->handle_onion_message_meth != NULL);
13542         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
13543         CHECK(calls->peer_connected_meth != NULL);
13544         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
13545         CHECK(calls->peer_disconnected_meth != NULL);
13546         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
13547         CHECK(calls->provided_node_features_meth != NULL);
13548         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
13549         CHECK(calls->provided_init_features_meth != NULL);
13550
13551         LDKOnionMessageHandler ret = {
13552                 .this_arg = (void*) calls,
13553                 .handle_onion_message = handle_onion_message_LDKOnionMessageHandler_jcall,
13554                 .peer_connected = peer_connected_LDKOnionMessageHandler_jcall,
13555                 .peer_disconnected = peer_disconnected_LDKOnionMessageHandler_jcall,
13556                 .provided_node_features = provided_node_features_LDKOnionMessageHandler_jcall,
13557                 .provided_init_features = provided_init_features_LDKOnionMessageHandler_jcall,
13558                 .free = LDKOnionMessageHandler_JCalls_free,
13559                 .OnionMessageProvider = LDKOnionMessageProvider_init(env, clz, OnionMessageProvider),
13560         };
13561         calls->OnionMessageProvider = ret.OnionMessageProvider.this_arg;
13562         return ret;
13563 }
13564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject OnionMessageProvider) {
13565         LDKOnionMessageHandler *res_ptr = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
13566         *res_ptr = LDKOnionMessageHandler_init(env, clz, o, OnionMessageProvider);
13567         return tag_ptr(res_ptr, true);
13568 }
13569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageHandler_1get_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t arg) {
13570         LDKOnionMessageHandler *inp = (LDKOnionMessageHandler *)untag_ptr(arg);
13571         return tag_ptr(&inp->OnionMessageProvider, false);
13572 }
13573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1handle_1onion_1message(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray peer_node_id, int64_t msg) {
13574         void* this_arg_ptr = untag_ptr(this_arg);
13575         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13576         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
13577         LDKPublicKey peer_node_id_ref;
13578         CHECK((*env)->GetArrayLength(env, peer_node_id) == 33);
13579         (*env)->GetByteArrayRegion(env, peer_node_id, 0, 33, peer_node_id_ref.compressed_form);
13580         LDKOnionMessage msg_conv;
13581         msg_conv.inner = untag_ptr(msg);
13582         msg_conv.is_owned = ptr_is_owned(msg);
13583         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13584         msg_conv.is_owned = false;
13585         (this_arg_conv->handle_onion_message)(this_arg_conv->this_arg, peer_node_id_ref, &msg_conv);
13586 }
13587
13588 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1peer_1connected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t init) {
13589         void* this_arg_ptr = untag_ptr(this_arg);
13590         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13591         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
13592         LDKPublicKey their_node_id_ref;
13593         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13594         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13595         LDKInit init_conv;
13596         init_conv.inner = untag_ptr(init);
13597         init_conv.is_owned = ptr_is_owned(init);
13598         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
13599         init_conv.is_owned = false;
13600         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
13601 }
13602
13603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1peer_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
13604         void* this_arg_ptr = untag_ptr(this_arg);
13605         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13606         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
13607         LDKPublicKey their_node_id_ref;
13608         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13609         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13610         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
13611 }
13612
13613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
13614         void* this_arg_ptr = untag_ptr(this_arg);
13615         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13616         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
13617         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
13618         int64_t ret_ref = 0;
13619         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13620         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13621         return ret_ref;
13622 }
13623
13624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1provided_1init_1features(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id) {
13625         void* this_arg_ptr = untag_ptr(this_arg);
13626         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13627         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
13628         LDKPublicKey their_node_id_ref;
13629         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13630         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13631         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
13632         int64_t ret_ref = 0;
13633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13634         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13635         return ret_ref;
13636 }
13637
13638 typedef struct LDKCustomMessageReader_JCalls {
13639         atomic_size_t refcnt;
13640         JavaVM *vm;
13641         jweak o;
13642         jmethodID read_meth;
13643 } LDKCustomMessageReader_JCalls;
13644 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
13645         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
13646         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13647                 JNIEnv *env;
13648                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13649                 if (get_jenv_res == JNI_EDETACHED) {
13650                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13651                 } else {
13652                         DO_ASSERT(get_jenv_res == JNI_OK);
13653                 }
13654                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13655                 if (get_jenv_res == JNI_EDETACHED) {
13656                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13657                 }
13658                 FREE(j_calls);
13659         }
13660 }
13661 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
13662         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
13663         JNIEnv *env;
13664         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13665         if (get_jenv_res == JNI_EDETACHED) {
13666                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13667         } else {
13668                 DO_ASSERT(get_jenv_res == JNI_OK);
13669         }
13670         int16_t message_type_conv = message_type;
13671         LDKu8slice buffer_var = buffer;
13672         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
13673         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
13674         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13675         CHECK(obj != NULL);
13676         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type_conv, buffer_arr);
13677         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13678                 (*env)->ExceptionDescribe(env);
13679                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
13680         }
13681         void* ret_ptr = untag_ptr(ret);
13682         CHECK_ACCESS(ret_ptr);
13683         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
13684         FREE(untag_ptr(ret));
13685         if (get_jenv_res == JNI_EDETACHED) {
13686                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13687         }
13688         return ret_conv;
13689 }
13690 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
13691         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
13692         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13693 }
13694 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
13695         jclass c = (*env)->GetObjectClass(env, o);
13696         CHECK(c != NULL);
13697         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
13698         atomic_init(&calls->refcnt, 1);
13699         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13700         calls->o = (*env)->NewWeakGlobalRef(env, o);
13701         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
13702         CHECK(calls->read_meth != NULL);
13703
13704         LDKCustomMessageReader ret = {
13705                 .this_arg = (void*) calls,
13706                 .read = read_LDKCustomMessageReader_jcall,
13707                 .free = LDKCustomMessageReader_JCalls_free,
13708         };
13709         return ret;
13710 }
13711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
13712         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
13713         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
13714         return tag_ptr(res_ptr, true);
13715 }
13716 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) {
13717         void* this_arg_ptr = untag_ptr(this_arg);
13718         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13719         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
13720         LDKu8slice buffer_ref;
13721         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
13722         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
13723         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
13724         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
13725         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
13726         return tag_ptr(ret_conv, true);
13727 }
13728
13729 typedef struct LDKCustomMessageHandler_JCalls {
13730         atomic_size_t refcnt;
13731         JavaVM *vm;
13732         jweak o;
13733         LDKCustomMessageReader_JCalls* CustomMessageReader;
13734         jmethodID handle_custom_message_meth;
13735         jmethodID get_and_clear_pending_msg_meth;
13736 } LDKCustomMessageHandler_JCalls;
13737 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
13738         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13739         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13740                 JNIEnv *env;
13741                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13742                 if (get_jenv_res == JNI_EDETACHED) {
13743                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13744                 } else {
13745                         DO_ASSERT(get_jenv_res == JNI_OK);
13746                 }
13747                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13748                 if (get_jenv_res == JNI_EDETACHED) {
13749                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13750                 }
13751                 FREE(j_calls);
13752         }
13753 }
13754 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
13755         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13756         JNIEnv *env;
13757         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13758         if (get_jenv_res == JNI_EDETACHED) {
13759                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13760         } else {
13761                 DO_ASSERT(get_jenv_res == JNI_OK);
13762         }
13763         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
13764         *msg_ret = msg;
13765         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
13766         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
13767         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13768         CHECK(obj != NULL);
13769         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, tag_ptr(msg_ret, true), sender_node_id_arr);
13770         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13771                 (*env)->ExceptionDescribe(env);
13772                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
13773         }
13774         void* ret_ptr = untag_ptr(ret);
13775         CHECK_ACCESS(ret_ptr);
13776         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13777         FREE(untag_ptr(ret));
13778         if (get_jenv_res == JNI_EDETACHED) {
13779                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13780         }
13781         return ret_conv;
13782 }
13783 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
13784         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
13785         JNIEnv *env;
13786         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13787         if (get_jenv_res == JNI_EDETACHED) {
13788                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13789         } else {
13790                 DO_ASSERT(get_jenv_res == JNI_OK);
13791         }
13792         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13793         CHECK(obj != NULL);
13794         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
13795         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13796                 (*env)->ExceptionDescribe(env);
13797                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
13798         }
13799         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
13800         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
13801         if (ret_constr.datalen > 0)
13802                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
13803         else
13804                 ret_constr.data = NULL;
13805         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
13806         for (size_t z = 0; z < ret_constr.datalen; z++) {
13807                 int64_t ret_conv_25 = ret_vals[z];
13808                 void* ret_conv_25_ptr = untag_ptr(ret_conv_25);
13809                 CHECK_ACCESS(ret_conv_25_ptr);
13810                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
13811                 FREE(untag_ptr(ret_conv_25));
13812                 ret_constr.data[z] = ret_conv_25_conv;
13813         }
13814         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
13815         if (get_jenv_res == JNI_EDETACHED) {
13816                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13817         }
13818         return ret_constr;
13819 }
13820 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
13821         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
13822         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13823         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
13824 }
13825 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
13826         jclass c = (*env)->GetObjectClass(env, o);
13827         CHECK(c != NULL);
13828         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
13829         atomic_init(&calls->refcnt, 1);
13830         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13831         calls->o = (*env)->NewWeakGlobalRef(env, o);
13832         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
13833         CHECK(calls->handle_custom_message_meth != NULL);
13834         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
13835         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
13836
13837         LDKCustomMessageHandler ret = {
13838                 .this_arg = (void*) calls,
13839                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
13840                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
13841                 .free = LDKCustomMessageHandler_JCalls_free,
13842                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
13843         };
13844         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
13845         return ret;
13846 }
13847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
13848         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
13849         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
13850         return tag_ptr(res_ptr, true);
13851 }
13852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
13853         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)untag_ptr(arg);
13854         return tag_ptr(&inp->CustomMessageReader, false);
13855 }
13856 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) {
13857         void* this_arg_ptr = untag_ptr(this_arg);
13858         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13859         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
13860         void* msg_ptr = untag_ptr(msg);
13861         CHECK_ACCESS(msg_ptr);
13862         LDKType msg_conv = *(LDKType*)(msg_ptr);
13863         if (msg_conv.free == LDKType_JCalls_free) {
13864                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13865                 LDKType_JCalls_cloned(&msg_conv);
13866         }
13867         LDKPublicKey sender_node_id_ref;
13868         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
13869         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
13870         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13871         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
13872         return tag_ptr(ret_conv, true);
13873 }
13874
13875 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
13876         void* this_arg_ptr = untag_ptr(this_arg);
13877         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13878         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
13879         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
13880         int64_tArray ret_arr = NULL;
13881         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
13882         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
13883         for (size_t z = 0; z < ret_var.datalen; z++) {
13884                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
13885                 *ret_conv_25_conv = ret_var.data[z];
13886                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_conv, true);
13887         }
13888         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
13889         FREE(ret_var.data);
13890         return ret_arr;
13891 }
13892
13893 typedef struct LDKSocketDescriptor_JCalls {
13894         atomic_size_t refcnt;
13895         JavaVM *vm;
13896         jweak o;
13897         jmethodID send_data_meth;
13898         jmethodID disconnect_socket_meth;
13899         jmethodID eq_meth;
13900         jmethodID hash_meth;
13901 } LDKSocketDescriptor_JCalls;
13902 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
13903         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13904         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13905                 JNIEnv *env;
13906                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13907                 if (get_jenv_res == JNI_EDETACHED) {
13908                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13909                 } else {
13910                         DO_ASSERT(get_jenv_res == JNI_OK);
13911                 }
13912                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13913                 if (get_jenv_res == JNI_EDETACHED) {
13914                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13915                 }
13916                 FREE(j_calls);
13917         }
13918 }
13919 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
13920         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13921         JNIEnv *env;
13922         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13923         if (get_jenv_res == JNI_EDETACHED) {
13924                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13925         } else {
13926                 DO_ASSERT(get_jenv_res == JNI_OK);
13927         }
13928         LDKu8slice data_var = data;
13929         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
13930         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
13931         jboolean resume_read_conv = resume_read;
13932         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13933         CHECK(obj != NULL);
13934         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read_conv);
13935         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13936                 (*env)->ExceptionDescribe(env);
13937                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
13938         }
13939         if (get_jenv_res == JNI_EDETACHED) {
13940                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13941         }
13942         return ret;
13943 }
13944 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
13945         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13946         JNIEnv *env;
13947         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13948         if (get_jenv_res == JNI_EDETACHED) {
13949                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13950         } else {
13951                 DO_ASSERT(get_jenv_res == JNI_OK);
13952         }
13953         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13954         CHECK(obj != NULL);
13955         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
13956         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13957                 (*env)->ExceptionDescribe(env);
13958                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
13959         }
13960         if (get_jenv_res == JNI_EDETACHED) {
13961                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13962         }
13963 }
13964 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
13965         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13966         JNIEnv *env;
13967         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13968         if (get_jenv_res == JNI_EDETACHED) {
13969                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13970         } else {
13971                 DO_ASSERT(get_jenv_res == JNI_OK);
13972         }
13973         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
13974         *other_arg_clone = SocketDescriptor_clone(other_arg);
13975         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13976         CHECK(obj != NULL);
13977         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, tag_ptr(other_arg_clone, true));
13978         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13979                 (*env)->ExceptionDescribe(env);
13980                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
13981         }
13982         if (get_jenv_res == JNI_EDETACHED) {
13983                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13984         }
13985         return ret;
13986 }
13987 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
13988         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
13989         JNIEnv *env;
13990         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13991         if (get_jenv_res == JNI_EDETACHED) {
13992                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13993         } else {
13994                 DO_ASSERT(get_jenv_res == JNI_OK);
13995         }
13996         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13997         CHECK(obj != NULL);
13998         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
13999         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14000                 (*env)->ExceptionDescribe(env);
14001                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
14002         }
14003         if (get_jenv_res == JNI_EDETACHED) {
14004                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14005         }
14006         return ret;
14007 }
14008 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
14009         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
14010         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14011 }
14012 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
14013         jclass c = (*env)->GetObjectClass(env, o);
14014         CHECK(c != NULL);
14015         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
14016         atomic_init(&calls->refcnt, 1);
14017         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14018         calls->o = (*env)->NewWeakGlobalRef(env, o);
14019         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
14020         CHECK(calls->send_data_meth != NULL);
14021         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
14022         CHECK(calls->disconnect_socket_meth != NULL);
14023         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
14024         CHECK(calls->eq_meth != NULL);
14025         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
14026         CHECK(calls->hash_meth != NULL);
14027
14028         LDKSocketDescriptor ret = {
14029                 .this_arg = (void*) calls,
14030                 .send_data = send_data_LDKSocketDescriptor_jcall,
14031                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
14032                 .eq = eq_LDKSocketDescriptor_jcall,
14033                 .hash = hash_LDKSocketDescriptor_jcall,
14034                 .cloned = LDKSocketDescriptor_JCalls_cloned,
14035                 .free = LDKSocketDescriptor_JCalls_free,
14036         };
14037         return ret;
14038 }
14039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
14040         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
14041         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
14042         return tag_ptr(res_ptr, true);
14043 }
14044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1send_1data(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray data, jboolean resume_read) {
14045         void* this_arg_ptr = untag_ptr(this_arg);
14046         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14047         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14048         LDKu8slice data_ref;
14049         data_ref.datalen = (*env)->GetArrayLength(env, data);
14050         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
14051         int64_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
14052         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
14053         return ret_conv;
14054 }
14055
14056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
14057         void* this_arg_ptr = untag_ptr(this_arg);
14058         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14059         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14060         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
14061 }
14062
14063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
14064         void* this_arg_ptr = untag_ptr(this_arg);
14065         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14066         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14067         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
14068         return ret_conv;
14069 }
14070
14071 static jclass LDKEffectiveCapacity_ExactLiquidity_class = NULL;
14072 static jmethodID LDKEffectiveCapacity_ExactLiquidity_meth = NULL;
14073 static jclass LDKEffectiveCapacity_MaximumHTLC_class = NULL;
14074 static jmethodID LDKEffectiveCapacity_MaximumHTLC_meth = NULL;
14075 static jclass LDKEffectiveCapacity_Total_class = NULL;
14076 static jmethodID LDKEffectiveCapacity_Total_meth = NULL;
14077 static jclass LDKEffectiveCapacity_Infinite_class = NULL;
14078 static jmethodID LDKEffectiveCapacity_Infinite_meth = NULL;
14079 static jclass LDKEffectiveCapacity_Unknown_class = NULL;
14080 static jmethodID LDKEffectiveCapacity_Unknown_meth = NULL;
14081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEffectiveCapacity_init (JNIEnv *env, jclass clz) {
14082         LDKEffectiveCapacity_ExactLiquidity_class =
14083                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$ExactLiquidity"));
14084         CHECK(LDKEffectiveCapacity_ExactLiquidity_class != NULL);
14085         LDKEffectiveCapacity_ExactLiquidity_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_ExactLiquidity_class, "<init>", "(J)V");
14086         CHECK(LDKEffectiveCapacity_ExactLiquidity_meth != NULL);
14087         LDKEffectiveCapacity_MaximumHTLC_class =
14088                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$MaximumHTLC"));
14089         CHECK(LDKEffectiveCapacity_MaximumHTLC_class != NULL);
14090         LDKEffectiveCapacity_MaximumHTLC_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_MaximumHTLC_class, "<init>", "(J)V");
14091         CHECK(LDKEffectiveCapacity_MaximumHTLC_meth != NULL);
14092         LDKEffectiveCapacity_Total_class =
14093                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Total"));
14094         CHECK(LDKEffectiveCapacity_Total_class != NULL);
14095         LDKEffectiveCapacity_Total_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Total_class, "<init>", "(JJ)V");
14096         CHECK(LDKEffectiveCapacity_Total_meth != NULL);
14097         LDKEffectiveCapacity_Infinite_class =
14098                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Infinite"));
14099         CHECK(LDKEffectiveCapacity_Infinite_class != NULL);
14100         LDKEffectiveCapacity_Infinite_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Infinite_class, "<init>", "()V");
14101         CHECK(LDKEffectiveCapacity_Infinite_meth != NULL);
14102         LDKEffectiveCapacity_Unknown_class =
14103                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Unknown"));
14104         CHECK(LDKEffectiveCapacity_Unknown_class != NULL);
14105         LDKEffectiveCapacity_Unknown_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Unknown_class, "<init>", "()V");
14106         CHECK(LDKEffectiveCapacity_Unknown_meth != NULL);
14107 }
14108 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEffectiveCapacity_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14109         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
14110         switch(obj->tag) {
14111                 case LDKEffectiveCapacity_ExactLiquidity: {
14112                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
14113                         return (*env)->NewObject(env, LDKEffectiveCapacity_ExactLiquidity_class, LDKEffectiveCapacity_ExactLiquidity_meth, liquidity_msat_conv);
14114                 }
14115                 case LDKEffectiveCapacity_MaximumHTLC: {
14116                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
14117                         return (*env)->NewObject(env, LDKEffectiveCapacity_MaximumHTLC_class, LDKEffectiveCapacity_MaximumHTLC_meth, amount_msat_conv);
14118                 }
14119                 case LDKEffectiveCapacity_Total: {
14120                         int64_t capacity_msat_conv = obj->total.capacity_msat;
14121                         int64_t htlc_maximum_msat_ref = tag_ptr(&obj->total.htlc_maximum_msat, false);
14122                         return (*env)->NewObject(env, LDKEffectiveCapacity_Total_class, LDKEffectiveCapacity_Total_meth, capacity_msat_conv, htlc_maximum_msat_ref);
14123                 }
14124                 case LDKEffectiveCapacity_Infinite: {
14125                         return (*env)->NewObject(env, LDKEffectiveCapacity_Infinite_class, LDKEffectiveCapacity_Infinite_meth);
14126                 }
14127                 case LDKEffectiveCapacity_Unknown: {
14128                         return (*env)->NewObject(env, LDKEffectiveCapacity_Unknown_class, LDKEffectiveCapacity_Unknown_meth);
14129                 }
14130                 default: abort();
14131         }
14132 }
14133 static jclass LDKDestination_Node_class = NULL;
14134 static jmethodID LDKDestination_Node_meth = NULL;
14135 static jclass LDKDestination_BlindedRoute_class = NULL;
14136 static jmethodID LDKDestination_BlindedRoute_meth = NULL;
14137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKDestination_init (JNIEnv *env, jclass clz) {
14138         LDKDestination_Node_class =
14139                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDestination$Node"));
14140         CHECK(LDKDestination_Node_class != NULL);
14141         LDKDestination_Node_meth = (*env)->GetMethodID(env, LDKDestination_Node_class, "<init>", "([B)V");
14142         CHECK(LDKDestination_Node_meth != NULL);
14143         LDKDestination_BlindedRoute_class =
14144                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDestination$BlindedRoute"));
14145         CHECK(LDKDestination_BlindedRoute_class != NULL);
14146         LDKDestination_BlindedRoute_meth = (*env)->GetMethodID(env, LDKDestination_BlindedRoute_class, "<init>", "(J)V");
14147         CHECK(LDKDestination_BlindedRoute_meth != NULL);
14148 }
14149 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKDestination_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14150         LDKDestination *obj = (LDKDestination*)untag_ptr(ptr);
14151         switch(obj->tag) {
14152                 case LDKDestination_Node: {
14153                         int8_tArray node_arr = (*env)->NewByteArray(env, 33);
14154                         (*env)->SetByteArrayRegion(env, node_arr, 0, 33, obj->node.compressed_form);
14155                         return (*env)->NewObject(env, LDKDestination_Node_class, LDKDestination_Node_meth, node_arr);
14156                 }
14157                 case LDKDestination_BlindedRoute: {
14158                         LDKBlindedRoute blinded_route_var = obj->blinded_route;
14159                         int64_t blinded_route_ref = 0;
14160                         CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_route_var);
14161                         blinded_route_ref = tag_ptr(blinded_route_var.inner, false);
14162                         return (*env)->NewObject(env, LDKDestination_BlindedRoute_class, LDKDestination_BlindedRoute_meth, blinded_route_ref);
14163                 }
14164                 default: abort();
14165         }
14166 }
14167 static jclass LDKGossipSync_P2P_class = NULL;
14168 static jmethodID LDKGossipSync_P2P_meth = NULL;
14169 static jclass LDKGossipSync_Rapid_class = NULL;
14170 static jmethodID LDKGossipSync_Rapid_meth = NULL;
14171 static jclass LDKGossipSync_None_class = NULL;
14172 static jmethodID LDKGossipSync_None_meth = NULL;
14173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGossipSync_init (JNIEnv *env, jclass clz) {
14174         LDKGossipSync_P2P_class =
14175                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$P2P"));
14176         CHECK(LDKGossipSync_P2P_class != NULL);
14177         LDKGossipSync_P2P_meth = (*env)->GetMethodID(env, LDKGossipSync_P2P_class, "<init>", "(J)V");
14178         CHECK(LDKGossipSync_P2P_meth != NULL);
14179         LDKGossipSync_Rapid_class =
14180                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$Rapid"));
14181         CHECK(LDKGossipSync_Rapid_class != NULL);
14182         LDKGossipSync_Rapid_meth = (*env)->GetMethodID(env, LDKGossipSync_Rapid_class, "<init>", "(J)V");
14183         CHECK(LDKGossipSync_Rapid_meth != NULL);
14184         LDKGossipSync_None_class =
14185                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$None"));
14186         CHECK(LDKGossipSync_None_class != NULL);
14187         LDKGossipSync_None_meth = (*env)->GetMethodID(env, LDKGossipSync_None_class, "<init>", "()V");
14188         CHECK(LDKGossipSync_None_meth != NULL);
14189 }
14190 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGossipSync_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14191         LDKGossipSync *obj = (LDKGossipSync*)untag_ptr(ptr);
14192         switch(obj->tag) {
14193                 case LDKGossipSync_P2P: {
14194                         LDKP2PGossipSync p2p_var = obj->p2p;
14195                         int64_t p2p_ref = 0;
14196                         CHECK_INNER_FIELD_ACCESS_OR_NULL(p2p_var);
14197                         p2p_ref = tag_ptr(p2p_var.inner, false);
14198                         return (*env)->NewObject(env, LDKGossipSync_P2P_class, LDKGossipSync_P2P_meth, p2p_ref);
14199                 }
14200                 case LDKGossipSync_Rapid: {
14201                         LDKRapidGossipSync rapid_var = obj->rapid;
14202                         int64_t rapid_ref = 0;
14203                         CHECK_INNER_FIELD_ACCESS_OR_NULL(rapid_var);
14204                         rapid_ref = tag_ptr(rapid_var.inner, false);
14205                         return (*env)->NewObject(env, LDKGossipSync_Rapid_class, LDKGossipSync_Rapid_meth, rapid_ref);
14206                 }
14207                 case LDKGossipSync_None: {
14208                         return (*env)->NewObject(env, LDKGossipSync_None_class, LDKGossipSync_None_meth);
14209                 }
14210                 default: abort();
14211         }
14212 }
14213 static jclass LDKFallback_SegWitProgram_class = NULL;
14214 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
14215 static jclass LDKFallback_PubKeyHash_class = NULL;
14216 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
14217 static jclass LDKFallback_ScriptHash_class = NULL;
14218 static jmethodID LDKFallback_ScriptHash_meth = NULL;
14219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
14220         LDKFallback_SegWitProgram_class =
14221                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
14222         CHECK(LDKFallback_SegWitProgram_class != NULL);
14223         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
14224         CHECK(LDKFallback_SegWitProgram_meth != NULL);
14225         LDKFallback_PubKeyHash_class =
14226                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
14227         CHECK(LDKFallback_PubKeyHash_class != NULL);
14228         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
14229         CHECK(LDKFallback_PubKeyHash_meth != NULL);
14230         LDKFallback_ScriptHash_class =
14231                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
14232         CHECK(LDKFallback_ScriptHash_class != NULL);
14233         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
14234         CHECK(LDKFallback_ScriptHash_meth != NULL);
14235 }
14236 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14237         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
14238         switch(obj->tag) {
14239                 case LDKFallback_SegWitProgram: {
14240                         uint8_t version_val = obj->seg_wit_program.version._0;
14241                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
14242                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
14243                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
14244                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
14245                 }
14246                 case LDKFallback_PubKeyHash: {
14247                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
14248                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
14249                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
14250                 }
14251                 case LDKFallback_ScriptHash: {
14252                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
14253                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
14254                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
14255                 }
14256                 default: abort();
14257         }
14258 }
14259 typedef struct LDKPayer_JCalls {
14260         atomic_size_t refcnt;
14261         JavaVM *vm;
14262         jweak o;
14263         jmethodID node_id_meth;
14264         jmethodID first_hops_meth;
14265         jmethodID send_payment_meth;
14266         jmethodID send_spontaneous_payment_meth;
14267         jmethodID retry_payment_meth;
14268         jmethodID abandon_payment_meth;
14269 } LDKPayer_JCalls;
14270 static void LDKPayer_JCalls_free(void* this_arg) {
14271         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14272         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14273                 JNIEnv *env;
14274                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14275                 if (get_jenv_res == JNI_EDETACHED) {
14276                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14277                 } else {
14278                         DO_ASSERT(get_jenv_res == JNI_OK);
14279                 }
14280                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14281                 if (get_jenv_res == JNI_EDETACHED) {
14282                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14283                 }
14284                 FREE(j_calls);
14285         }
14286 }
14287 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
14288         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14289         JNIEnv *env;
14290         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14291         if (get_jenv_res == JNI_EDETACHED) {
14292                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14293         } else {
14294                 DO_ASSERT(get_jenv_res == JNI_OK);
14295         }
14296         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14297         CHECK(obj != NULL);
14298         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
14299         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14300                 (*env)->ExceptionDescribe(env);
14301                 (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
14302         }
14303         LDKPublicKey ret_ref;
14304         CHECK((*env)->GetArrayLength(env, ret) == 33);
14305         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
14306         if (get_jenv_res == JNI_EDETACHED) {
14307                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14308         }
14309         return ret_ref;
14310 }
14311 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
14312         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14313         JNIEnv *env;
14314         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14315         if (get_jenv_res == JNI_EDETACHED) {
14316                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14317         } else {
14318                 DO_ASSERT(get_jenv_res == JNI_OK);
14319         }
14320         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14321         CHECK(obj != NULL);
14322         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
14323         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14324                 (*env)->ExceptionDescribe(env);
14325                 (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
14326         }
14327         LDKCVec_ChannelDetailsZ ret_constr;
14328         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
14329         if (ret_constr.datalen > 0)
14330                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
14331         else
14332                 ret_constr.data = NULL;
14333         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
14334         for (size_t q = 0; q < ret_constr.datalen; q++) {
14335                 int64_t ret_conv_16 = ret_vals[q];
14336                 LDKChannelDetails ret_conv_16_conv;
14337                 ret_conv_16_conv.inner = untag_ptr(ret_conv_16);
14338                 ret_conv_16_conv.is_owned = ptr_is_owned(ret_conv_16);
14339                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
14340                 ret_constr.data[q] = ret_conv_16_conv;
14341         }
14342         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
14343         if (get_jenv_res == JNI_EDETACHED) {
14344                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14345         }
14346         return ret_constr;
14347 }
14348 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
14349         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14350         JNIEnv *env;
14351         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14352         if (get_jenv_res == JNI_EDETACHED) {
14353                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14354         } else {
14355                 DO_ASSERT(get_jenv_res == JNI_OK);
14356         }
14357         LDKRoute route_var = *route;
14358         int64_t route_ref = 0;
14359         route_var = Route_clone(&route_var);
14360         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14361         route_ref = tag_ptr(route_var.inner, route_var.is_owned);
14362         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
14363         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
14364         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
14365         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
14366         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14367         CHECK(obj != NULL);
14368         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
14369         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14370                 (*env)->ExceptionDescribe(env);
14371                 (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
14372         }
14373         void* ret_ptr = untag_ptr(ret);
14374         CHECK_ACCESS(ret_ptr);
14375         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
14376         FREE(untag_ptr(ret));
14377         if (get_jenv_res == JNI_EDETACHED) {
14378                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14379         }
14380         return ret_conv;
14381 }
14382 LDKCResult_PaymentIdPaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage) {
14383         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14384         JNIEnv *env;
14385         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14386         if (get_jenv_res == JNI_EDETACHED) {
14387                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14388         } else {
14389                 DO_ASSERT(get_jenv_res == JNI_OK);
14390         }
14391         LDKRoute route_var = *route;
14392         int64_t route_ref = 0;
14393         route_var = Route_clone(&route_var);
14394         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14395         route_ref = tag_ptr(route_var.inner, route_var.is_owned);
14396         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
14397         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, payment_preimage.data);
14398         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14399         CHECK(obj != NULL);
14400         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_spontaneous_payment_meth, route_ref, payment_preimage_arr);
14401         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14402                 (*env)->ExceptionDescribe(env);
14403                 (*env)->FatalError(env, "A call to send_spontaneous_payment in LDKPayer from rust threw an exception.");
14404         }
14405         void* ret_ptr = untag_ptr(ret);
14406         CHECK_ACCESS(ret_ptr);
14407         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
14408         FREE(untag_ptr(ret));
14409         if (get_jenv_res == JNI_EDETACHED) {
14410                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14411         }
14412         return ret_conv;
14413 }
14414 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
14415         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14416         JNIEnv *env;
14417         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14418         if (get_jenv_res == JNI_EDETACHED) {
14419                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14420         } else {
14421                 DO_ASSERT(get_jenv_res == JNI_OK);
14422         }
14423         LDKRoute route_var = *route;
14424         int64_t route_ref = 0;
14425         route_var = Route_clone(&route_var);
14426         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
14427         route_ref = tag_ptr(route_var.inner, route_var.is_owned);
14428         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
14429         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
14430         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14431         CHECK(obj != NULL);
14432         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
14433         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14434                 (*env)->ExceptionDescribe(env);
14435                 (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
14436         }
14437         void* ret_ptr = untag_ptr(ret);
14438         CHECK_ACCESS(ret_ptr);
14439         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
14440         FREE(untag_ptr(ret));
14441         if (get_jenv_res == JNI_EDETACHED) {
14442                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14443         }
14444         return ret_conv;
14445 }
14446 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
14447         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
14448         JNIEnv *env;
14449         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14450         if (get_jenv_res == JNI_EDETACHED) {
14451                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14452         } else {
14453                 DO_ASSERT(get_jenv_res == JNI_OK);
14454         }
14455         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
14456         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
14457         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14458         CHECK(obj != NULL);
14459         (*env)->CallVoidMethod(env, obj, j_calls->abandon_payment_meth, payment_id_arr);
14460         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14461                 (*env)->ExceptionDescribe(env);
14462                 (*env)->FatalError(env, "A call to abandon_payment in LDKPayer from rust threw an exception.");
14463         }
14464         if (get_jenv_res == JNI_EDETACHED) {
14465                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14466         }
14467 }
14468 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
14469         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
14470         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14471 }
14472 static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
14473         jclass c = (*env)->GetObjectClass(env, o);
14474         CHECK(c != NULL);
14475         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
14476         atomic_init(&calls->refcnt, 1);
14477         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14478         calls->o = (*env)->NewWeakGlobalRef(env, o);
14479         calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
14480         CHECK(calls->node_id_meth != NULL);
14481         calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
14482         CHECK(calls->first_hops_meth != NULL);
14483         calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
14484         CHECK(calls->send_payment_meth != NULL);
14485         calls->send_spontaneous_payment_meth = (*env)->GetMethodID(env, c, "send_spontaneous_payment", "(J[B)J");
14486         CHECK(calls->send_spontaneous_payment_meth != NULL);
14487         calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
14488         CHECK(calls->retry_payment_meth != NULL);
14489         calls->abandon_payment_meth = (*env)->GetMethodID(env, c, "abandon_payment", "([B)V");
14490         CHECK(calls->abandon_payment_meth != NULL);
14491
14492         LDKPayer ret = {
14493                 .this_arg = (void*) calls,
14494                 .node_id = node_id_LDKPayer_jcall,
14495                 .first_hops = first_hops_LDKPayer_jcall,
14496                 .send_payment = send_payment_LDKPayer_jcall,
14497                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
14498                 .retry_payment = retry_payment_LDKPayer_jcall,
14499                 .abandon_payment = abandon_payment_LDKPayer_jcall,
14500                 .free = LDKPayer_JCalls_free,
14501         };
14502         return ret;
14503 }
14504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
14505         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
14506         *res_ptr = LDKPayer_init(env, clz, o);
14507         return tag_ptr(res_ptr, true);
14508 }
14509 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
14510         void* this_arg_ptr = untag_ptr(this_arg);
14511         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14512         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14513         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
14514         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
14515         return ret_arr;
14516 }
14517
14518 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
14519         void* this_arg_ptr = untag_ptr(this_arg);
14520         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14521         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14522         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
14523         int64_tArray ret_arr = NULL;
14524         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14525         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14526         for (size_t q = 0; q < ret_var.datalen; q++) {
14527                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
14528                 int64_t ret_conv_16_ref = 0;
14529                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
14530                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
14531                 ret_arr_ptr[q] = ret_conv_16_ref;
14532         }
14533         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14534         FREE(ret_var.data);
14535         return ret_arr;
14536 }
14537
14538 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) {
14539         void* this_arg_ptr = untag_ptr(this_arg);
14540         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14541         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14542         LDKRoute route_conv;
14543         route_conv.inner = untag_ptr(route);
14544         route_conv.is_owned = ptr_is_owned(route);
14545         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14546         route_conv.is_owned = false;
14547         LDKThirtyTwoBytes payment_hash_ref;
14548         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
14549         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
14550         LDKThirtyTwoBytes payment_secret_ref;
14551         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
14552         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
14553         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14554         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
14555         return tag_ptr(ret_conv, true);
14556 }
14557
14558 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) {
14559         void* this_arg_ptr = untag_ptr(this_arg);
14560         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14561         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14562         LDKRoute route_conv;
14563         route_conv.inner = untag_ptr(route);
14564         route_conv.is_owned = ptr_is_owned(route);
14565         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14566         route_conv.is_owned = false;
14567         LDKThirtyTwoBytes payment_preimage_ref;
14568         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
14569         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
14570         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14571         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref);
14572         return tag_ptr(ret_conv, true);
14573 }
14574
14575 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) {
14576         void* this_arg_ptr = untag_ptr(this_arg);
14577         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14578         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14579         LDKRoute route_conv;
14580         route_conv.inner = untag_ptr(route);
14581         route_conv.is_owned = ptr_is_owned(route);
14582         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
14583         route_conv.is_owned = false;
14584         LDKThirtyTwoBytes payment_id_ref;
14585         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
14586         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
14587         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14588         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
14589         return tag_ptr(ret_conv, true);
14590 }
14591
14592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
14593         void* this_arg_ptr = untag_ptr(this_arg);
14594         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14595         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
14596         LDKThirtyTwoBytes payment_id_ref;
14597         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
14598         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
14599         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
14600 }
14601
14602 typedef struct LDKRouter_JCalls {
14603         atomic_size_t refcnt;
14604         JavaVM *vm;
14605         jweak o;
14606         jmethodID find_route_meth;
14607         jmethodID notify_payment_path_failed_meth;
14608         jmethodID notify_payment_path_successful_meth;
14609         jmethodID notify_payment_probe_successful_meth;
14610         jmethodID notify_payment_probe_failed_meth;
14611 } LDKRouter_JCalls;
14612 static void LDKRouter_JCalls_free(void* this_arg) {
14613         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14614         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14615                 JNIEnv *env;
14616                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14617                 if (get_jenv_res == JNI_EDETACHED) {
14618                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14619                 } else {
14620                         DO_ASSERT(get_jenv_res == JNI_OK);
14621                 }
14622                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14623                 if (get_jenv_res == JNI_EDETACHED) {
14624                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14625                 }
14626                 FREE(j_calls);
14627         }
14628 }
14629 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, LDKInFlightHtlcs inflight_htlcs) {
14630         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14631         JNIEnv *env;
14632         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14633         if (get_jenv_res == JNI_EDETACHED) {
14634                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14635         } else {
14636                 DO_ASSERT(get_jenv_res == JNI_OK);
14637         }
14638         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
14639         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
14640         LDKRouteParameters route_params_var = *route_params;
14641         int64_t route_params_ref = 0;
14642         route_params_var = RouteParameters_clone(&route_params_var);
14643         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
14644         route_params_ref = tag_ptr(route_params_var.inner, route_params_var.is_owned);
14645         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
14646         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, *payment_hash);
14647         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
14648         int64_tArray first_hops_arr = NULL;
14649         if (first_hops != NULL) {
14650                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
14651                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
14652                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
14653                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
14654                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
14655                         int64_t first_hops_conv_16_ref = 0;
14656                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
14657                         first_hops_conv_16_ref = tag_ptr(first_hops_conv_16_var.inner, first_hops_conv_16_var.is_owned);
14658                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
14659                 }
14660                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
14661         }
14662         LDKInFlightHtlcs inflight_htlcs_var = inflight_htlcs;
14663         int64_t inflight_htlcs_ref = 0;
14664         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_var);
14665         inflight_htlcs_ref = tag_ptr(inflight_htlcs_var.inner, inflight_htlcs_var.is_owned);
14666         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14667         CHECK(obj != NULL);
14668         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->find_route_meth, payer_arr, route_params_ref, payment_hash_arr, first_hops_arr, inflight_htlcs_ref);
14669         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14670                 (*env)->ExceptionDescribe(env);
14671                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
14672         }
14673         void* ret_ptr = untag_ptr(ret);
14674         CHECK_ACCESS(ret_ptr);
14675         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
14676         FREE(untag_ptr(ret));
14677         if (get_jenv_res == JNI_EDETACHED) {
14678                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14679         }
14680         return ret_conv;
14681 }
14682 void notify_payment_path_failed_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
14683         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14684         JNIEnv *env;
14685         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14686         if (get_jenv_res == JNI_EDETACHED) {
14687                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14688         } else {
14689                 DO_ASSERT(get_jenv_res == JNI_OK);
14690         }
14691         LDKCVec_RouteHopZ path_var = path;
14692         int64_tArray path_arr = NULL;
14693         path_arr = (*env)->NewLongArray(env, path_var.datalen);
14694         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
14695         for (size_t k = 0; k < path_var.datalen; k++) {
14696                 LDKRouteHop path_conv_10_var = path_var.data[k];
14697                 int64_t path_conv_10_ref = 0;
14698                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
14699                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
14700                 path_arr_ptr[k] = path_conv_10_ref;
14701         }
14702         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
14703         FREE(path_var.data);
14704         int64_t short_channel_id_conv = short_channel_id;
14705         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14706         CHECK(obj != NULL);
14707         (*env)->CallVoidMethod(env, obj, j_calls->notify_payment_path_failed_meth, path_arr, short_channel_id_conv);
14708         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14709                 (*env)->ExceptionDescribe(env);
14710                 (*env)->FatalError(env, "A call to notify_payment_path_failed in LDKRouter from rust threw an exception.");
14711         }
14712         if (get_jenv_res == JNI_EDETACHED) {
14713                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14714         }
14715 }
14716 void notify_payment_path_successful_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path) {
14717         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14718         JNIEnv *env;
14719         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14720         if (get_jenv_res == JNI_EDETACHED) {
14721                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14722         } else {
14723                 DO_ASSERT(get_jenv_res == JNI_OK);
14724         }
14725         LDKCVec_RouteHopZ path_var = path;
14726         int64_tArray path_arr = NULL;
14727         path_arr = (*env)->NewLongArray(env, path_var.datalen);
14728         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
14729         for (size_t k = 0; k < path_var.datalen; k++) {
14730                 LDKRouteHop path_conv_10_var = path_var.data[k];
14731                 int64_t path_conv_10_ref = 0;
14732                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
14733                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
14734                 path_arr_ptr[k] = path_conv_10_ref;
14735         }
14736         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
14737         FREE(path_var.data);
14738         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14739         CHECK(obj != NULL);
14740         (*env)->CallVoidMethod(env, obj, j_calls->notify_payment_path_successful_meth, path_arr);
14741         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14742                 (*env)->ExceptionDescribe(env);
14743                 (*env)->FatalError(env, "A call to notify_payment_path_successful in LDKRouter from rust threw an exception.");
14744         }
14745         if (get_jenv_res == JNI_EDETACHED) {
14746                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14747         }
14748 }
14749 void notify_payment_probe_successful_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path) {
14750         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14751         JNIEnv *env;
14752         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14753         if (get_jenv_res == JNI_EDETACHED) {
14754                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14755         } else {
14756                 DO_ASSERT(get_jenv_res == JNI_OK);
14757         }
14758         LDKCVec_RouteHopZ path_var = path;
14759         int64_tArray path_arr = NULL;
14760         path_arr = (*env)->NewLongArray(env, path_var.datalen);
14761         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
14762         for (size_t k = 0; k < path_var.datalen; k++) {
14763                 LDKRouteHop path_conv_10_var = path_var.data[k];
14764                 int64_t path_conv_10_ref = 0;
14765                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
14766                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
14767                 path_arr_ptr[k] = path_conv_10_ref;
14768         }
14769         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
14770         FREE(path_var.data);
14771         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14772         CHECK(obj != NULL);
14773         (*env)->CallVoidMethod(env, obj, j_calls->notify_payment_probe_successful_meth, path_arr);
14774         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14775                 (*env)->ExceptionDescribe(env);
14776                 (*env)->FatalError(env, "A call to notify_payment_probe_successful in LDKRouter from rust threw an exception.");
14777         }
14778         if (get_jenv_res == JNI_EDETACHED) {
14779                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14780         }
14781 }
14782 void notify_payment_probe_failed_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
14783         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14784         JNIEnv *env;
14785         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14786         if (get_jenv_res == JNI_EDETACHED) {
14787                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14788         } else {
14789                 DO_ASSERT(get_jenv_res == JNI_OK);
14790         }
14791         LDKCVec_RouteHopZ path_var = path;
14792         int64_tArray path_arr = NULL;
14793         path_arr = (*env)->NewLongArray(env, path_var.datalen);
14794         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
14795         for (size_t k = 0; k < path_var.datalen; k++) {
14796                 LDKRouteHop path_conv_10_var = path_var.data[k];
14797                 int64_t path_conv_10_ref = 0;
14798                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
14799                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
14800                 path_arr_ptr[k] = path_conv_10_ref;
14801         }
14802         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
14803         FREE(path_var.data);
14804         int64_t short_channel_id_conv = short_channel_id;
14805         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14806         CHECK(obj != NULL);
14807         (*env)->CallVoidMethod(env, obj, j_calls->notify_payment_probe_failed_meth, path_arr, short_channel_id_conv);
14808         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14809                 (*env)->ExceptionDescribe(env);
14810                 (*env)->FatalError(env, "A call to notify_payment_probe_failed in LDKRouter from rust threw an exception.");
14811         }
14812         if (get_jenv_res == JNI_EDETACHED) {
14813                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14814         }
14815 }
14816 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
14817         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
14818         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14819 }
14820 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
14821         jclass c = (*env)->GetObjectClass(env, o);
14822         CHECK(c != NULL);
14823         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
14824         atomic_init(&calls->refcnt, 1);
14825         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14826         calls->o = (*env)->NewWeakGlobalRef(env, o);
14827         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[B[JJ)J");
14828         CHECK(calls->find_route_meth != NULL);
14829         calls->notify_payment_path_failed_meth = (*env)->GetMethodID(env, c, "notify_payment_path_failed", "([JJ)V");
14830         CHECK(calls->notify_payment_path_failed_meth != NULL);
14831         calls->notify_payment_path_successful_meth = (*env)->GetMethodID(env, c, "notify_payment_path_successful", "([J)V");
14832         CHECK(calls->notify_payment_path_successful_meth != NULL);
14833         calls->notify_payment_probe_successful_meth = (*env)->GetMethodID(env, c, "notify_payment_probe_successful", "([J)V");
14834         CHECK(calls->notify_payment_probe_successful_meth != NULL);
14835         calls->notify_payment_probe_failed_meth = (*env)->GetMethodID(env, c, "notify_payment_probe_failed", "([JJ)V");
14836         CHECK(calls->notify_payment_probe_failed_meth != NULL);
14837
14838         LDKRouter ret = {
14839                 .this_arg = (void*) calls,
14840                 .find_route = find_route_LDKRouter_jcall,
14841                 .notify_payment_path_failed = notify_payment_path_failed_LDKRouter_jcall,
14842                 .notify_payment_path_successful = notify_payment_path_successful_LDKRouter_jcall,
14843                 .notify_payment_probe_successful = notify_payment_probe_successful_LDKRouter_jcall,
14844                 .notify_payment_probe_failed = notify_payment_probe_failed_LDKRouter_jcall,
14845                 .free = LDKRouter_JCalls_free,
14846         };
14847         return ret;
14848 }
14849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
14850         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
14851         *res_ptr = LDKRouter_init(env, clz, o);
14852         return tag_ptr(res_ptr, true);
14853 }
14854 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 inflight_htlcs) {
14855         void* this_arg_ptr = untag_ptr(this_arg);
14856         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14857         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
14858         LDKPublicKey payer_ref;
14859         CHECK((*env)->GetArrayLength(env, payer) == 33);
14860         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
14861         LDKRouteParameters route_params_conv;
14862         route_params_conv.inner = untag_ptr(route_params);
14863         route_params_conv.is_owned = ptr_is_owned(route_params);
14864         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
14865         route_params_conv.is_owned = false;
14866         unsigned char payment_hash_arr[32];
14867         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
14868         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
14869         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
14870         LDKCVec_ChannelDetailsZ first_hops_constr;
14871         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
14872         if (first_hops != NULL) {
14873                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
14874                 if (first_hops_constr.datalen > 0)
14875                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
14876                 else
14877                         first_hops_constr.data = NULL;
14878                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
14879                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
14880                         int64_t first_hops_conv_16 = first_hops_vals[q];
14881                         LDKChannelDetails first_hops_conv_16_conv;
14882                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
14883                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
14884                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
14885                         first_hops_conv_16_conv.is_owned = false;
14886                         first_hops_constr.data[q] = first_hops_conv_16_conv;
14887                 }
14888                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
14889                 first_hops_ptr = &first_hops_constr;
14890         }
14891         LDKInFlightHtlcs inflight_htlcs_conv;
14892         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
14893         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
14894         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
14895         // WARNING: we need a move here but no clone is available for LDKInFlightHtlcs
14896         
14897         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
14898         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &route_params_conv, payment_hash_ref, first_hops_ptr, inflight_htlcs_conv);
14899         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
14900         return tag_ptr(ret_conv, true);
14901 }
14902
14903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1notify_1payment_1path_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path, int64_t short_channel_id) {
14904         void* this_arg_ptr = untag_ptr(this_arg);
14905         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14906         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
14907         LDKCVec_RouteHopZ path_constr;
14908         path_constr.datalen = (*env)->GetArrayLength(env, path);
14909         if (path_constr.datalen > 0)
14910                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
14911         else
14912                 path_constr.data = NULL;
14913         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
14914         for (size_t k = 0; k < path_constr.datalen; k++) {
14915                 int64_t path_conv_10 = path_vals[k];
14916                 LDKRouteHop path_conv_10_conv;
14917                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
14918                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
14919                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
14920                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
14921                 path_constr.data[k] = path_conv_10_conv;
14922         }
14923         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
14924         (this_arg_conv->notify_payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
14925 }
14926
14927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1notify_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
14928         void* this_arg_ptr = untag_ptr(this_arg);
14929         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14930         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
14931         LDKCVec_RouteHopZ path_constr;
14932         path_constr.datalen = (*env)->GetArrayLength(env, path);
14933         if (path_constr.datalen > 0)
14934                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
14935         else
14936                 path_constr.data = NULL;
14937         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
14938         for (size_t k = 0; k < path_constr.datalen; k++) {
14939                 int64_t path_conv_10 = path_vals[k];
14940                 LDKRouteHop path_conv_10_conv;
14941                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
14942                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
14943                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
14944                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
14945                 path_constr.data[k] = path_conv_10_conv;
14946         }
14947         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
14948         (this_arg_conv->notify_payment_path_successful)(this_arg_conv->this_arg, path_constr);
14949 }
14950
14951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1notify_1payment_1probe_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
14952         void* this_arg_ptr = untag_ptr(this_arg);
14953         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14954         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
14955         LDKCVec_RouteHopZ path_constr;
14956         path_constr.datalen = (*env)->GetArrayLength(env, path);
14957         if (path_constr.datalen > 0)
14958                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
14959         else
14960                 path_constr.data = NULL;
14961         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
14962         for (size_t k = 0; k < path_constr.datalen; k++) {
14963                 int64_t path_conv_10 = path_vals[k];
14964                 LDKRouteHop path_conv_10_conv;
14965                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
14966                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
14967                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
14968                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
14969                 path_constr.data[k] = path_conv_10_conv;
14970         }
14971         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
14972         (this_arg_conv->notify_payment_probe_successful)(this_arg_conv->this_arg, path_constr);
14973 }
14974
14975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1notify_1payment_1probe_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path, int64_t short_channel_id) {
14976         void* this_arg_ptr = untag_ptr(this_arg);
14977         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14978         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
14979         LDKCVec_RouteHopZ path_constr;
14980         path_constr.datalen = (*env)->GetArrayLength(env, path);
14981         if (path_constr.datalen > 0)
14982                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
14983         else
14984                 path_constr.data = NULL;
14985         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
14986         for (size_t k = 0; k < path_constr.datalen; k++) {
14987                 int64_t path_conv_10 = path_vals[k];
14988                 LDKRouteHop path_conv_10_conv;
14989                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
14990                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
14991                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
14992                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
14993                 path_constr.data[k] = path_conv_10_conv;
14994         }
14995         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
14996         (this_arg_conv->notify_payment_probe_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
14997 }
14998
14999 static jclass LDKRetry_Attempts_class = NULL;
15000 static jmethodID LDKRetry_Attempts_meth = NULL;
15001 static jclass LDKRetry_Timeout_class = NULL;
15002 static jmethodID LDKRetry_Timeout_meth = NULL;
15003 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKRetry_init (JNIEnv *env, jclass clz) {
15004         LDKRetry_Attempts_class =
15005                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Attempts"));
15006         CHECK(LDKRetry_Attempts_class != NULL);
15007         LDKRetry_Attempts_meth = (*env)->GetMethodID(env, LDKRetry_Attempts_class, "<init>", "(J)V");
15008         CHECK(LDKRetry_Attempts_meth != NULL);
15009         LDKRetry_Timeout_class =
15010                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Timeout"));
15011         CHECK(LDKRetry_Timeout_class != NULL);
15012         LDKRetry_Timeout_meth = (*env)->GetMethodID(env, LDKRetry_Timeout_class, "<init>", "(J)V");
15013         CHECK(LDKRetry_Timeout_meth != NULL);
15014 }
15015 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRetry_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15016         LDKRetry *obj = (LDKRetry*)untag_ptr(ptr);
15017         switch(obj->tag) {
15018                 case LDKRetry_Attempts: {
15019                         int64_t attempts_conv = obj->attempts;
15020                         return (*env)->NewObject(env, LDKRetry_Attempts_class, LDKRetry_Attempts_meth, attempts_conv);
15021                 }
15022                 case LDKRetry_Timeout: {
15023                         int64_t timeout_conv = obj->timeout;
15024                         return (*env)->NewObject(env, LDKRetry_Timeout_class, LDKRetry_Timeout_meth, timeout_conv);
15025                 }
15026                 default: abort();
15027         }
15028 }
15029 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
15030         LDKStr ret_str = _ldk_get_compiled_version();
15031         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
15032         Str_free(ret_str);
15033         return ret_conv;
15034 }
15035
15036 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
15037         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
15038         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
15039         Str_free(ret_str);
15040         return ret_conv;
15041 }
15042
15043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1new(JNIEnv *env, jclass clz, int8_tArray big_endian_bytes) {
15044         LDKThirtyTwoBytes big_endian_bytes_ref;
15045         CHECK((*env)->GetArrayLength(env, big_endian_bytes) == 32);
15046         (*env)->GetByteArrayRegion(env, big_endian_bytes, 0, 32, big_endian_bytes_ref.data);
15047         LDKBigEndianScalar* ret_ref = MALLOC(sizeof(LDKBigEndianScalar), "LDKBigEndianScalar");
15048         *ret_ref = BigEndianScalar_new(big_endian_bytes_ref);
15049         return tag_ptr(ret_ref, true);
15050 }
15051
15052 static inline uint64_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
15053         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
15054         *ret_copy = Bech32Error_clone(arg);
15055         int64_t ret_ref = tag_ptr(ret_copy, true);
15056         return ret_ref;
15057 }
15058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15059         LDKBech32Error* arg_conv = (LDKBech32Error*)untag_ptr(arg);
15060         int64_t ret_conv = Bech32Error_clone_ptr(arg_conv);
15061         return ret_conv;
15062 }
15063
15064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15065         LDKBech32Error* orig_conv = (LDKBech32Error*)untag_ptr(orig);
15066         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
15067         *ret_copy = Bech32Error_clone(orig_conv);
15068         int64_t ret_ref = tag_ptr(ret_copy, true);
15069         return ret_ref;
15070 }
15071
15072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bech32Error_1free(JNIEnv *env, jclass clz, int64_t o) {
15073         if (!ptr_is_owned(o)) return;
15074         void* o_ptr = untag_ptr(o);
15075         CHECK_ACCESS(o_ptr);
15076         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
15077         FREE(untag_ptr(o));
15078         Bech32Error_free(o_conv);
15079 }
15080
15081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
15082         LDKTransaction _res_ref;
15083         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
15084         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
15085         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
15086         _res_ref.data_is_owned = true;
15087         Transaction_free(_res_ref);
15088 }
15089
15090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
15091         LDKCVec_u8Z script_pubkey_ref;
15092         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
15093         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
15094         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
15095         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15096         *ret_ref = TxOut_new(script_pubkey_ref, value);
15097         return tag_ptr(ret_ref, true);
15098 }
15099
15100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
15101         if (!ptr_is_owned(_res)) return;
15102         void* _res_ptr = untag_ptr(_res);
15103         CHECK_ACCESS(_res_ptr);
15104         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
15105         FREE(untag_ptr(_res));
15106         TxOut_free(_res_conv);
15107 }
15108
15109 static inline uint64_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
15110         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15111         *ret_ref = TxOut_clone(arg);
15112         return tag_ptr(ret_ref, true);
15113 }
15114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15115         LDKTxOut* arg_conv = (LDKTxOut*)untag_ptr(arg);
15116         int64_t ret_conv = TxOut_clone_ptr(arg_conv);
15117         return ret_conv;
15118 }
15119
15120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15121         LDKTxOut* orig_conv = (LDKTxOut*)untag_ptr(orig);
15122         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15123         *ret_ref = TxOut_clone(orig_conv);
15124         return tag_ptr(ret_ref, true);
15125 }
15126
15127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
15128         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
15129         Str_free(dummy);
15130 }
15131
15132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15133         LDKCVec_PublicKeyZ _res_constr;
15134         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15135         if (_res_constr.datalen > 0)
15136                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
15137         else
15138                 _res_constr.data = NULL;
15139         for (size_t i = 0; i < _res_constr.datalen; i++) {
15140                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
15141                 LDKPublicKey _res_conv_8_ref;
15142                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
15143                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
15144                 _res_constr.data[i] = _res_conv_8_ref;
15145         }
15146         CVec_PublicKeyZ_free(_res_constr);
15147 }
15148
15149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15150         LDKBlindedRoute o_conv;
15151         o_conv.inner = untag_ptr(o);
15152         o_conv.is_owned = ptr_is_owned(o);
15153         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15154         // WARNING: we need a move here but no clone is available for LDKBlindedRoute
15155         
15156         LDKCResult_BlindedRouteNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteNoneZ), "LDKCResult_BlindedRouteNoneZ");
15157         *ret_conv = CResult_BlindedRouteNoneZ_ok(o_conv);
15158         return tag_ptr(ret_conv, true);
15159 }
15160
15161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteNoneZ_1err(JNIEnv *env, jclass clz) {
15162         LDKCResult_BlindedRouteNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteNoneZ), "LDKCResult_BlindedRouteNoneZ");
15163         *ret_conv = CResult_BlindedRouteNoneZ_err();
15164         return tag_ptr(ret_conv, true);
15165 }
15166
15167 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15168         LDKCResult_BlindedRouteNoneZ* o_conv = (LDKCResult_BlindedRouteNoneZ*)untag_ptr(o);
15169         jboolean ret_conv = CResult_BlindedRouteNoneZ_is_ok(o_conv);
15170         return ret_conv;
15171 }
15172
15173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15174         if (!ptr_is_owned(_res)) return;
15175         void* _res_ptr = untag_ptr(_res);
15176         CHECK_ACCESS(_res_ptr);
15177         LDKCResult_BlindedRouteNoneZ _res_conv = *(LDKCResult_BlindedRouteNoneZ*)(_res_ptr);
15178         FREE(untag_ptr(_res));
15179         CResult_BlindedRouteNoneZ_free(_res_conv);
15180 }
15181
15182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15183         LDKBlindedRoute o_conv;
15184         o_conv.inner = untag_ptr(o);
15185         o_conv.is_owned = ptr_is_owned(o);
15186         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15187         // WARNING: we need a move here but no clone is available for LDKBlindedRoute
15188         
15189         LDKCResult_BlindedRouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteDecodeErrorZ), "LDKCResult_BlindedRouteDecodeErrorZ");
15190         *ret_conv = CResult_BlindedRouteDecodeErrorZ_ok(o_conv);
15191         return tag_ptr(ret_conv, true);
15192 }
15193
15194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15195         LDKDecodeError e_conv;
15196         e_conv.inner = untag_ptr(e);
15197         e_conv.is_owned = ptr_is_owned(e);
15198         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15199         e_conv = DecodeError_clone(&e_conv);
15200         LDKCResult_BlindedRouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteDecodeErrorZ), "LDKCResult_BlindedRouteDecodeErrorZ");
15201         *ret_conv = CResult_BlindedRouteDecodeErrorZ_err(e_conv);
15202         return tag_ptr(ret_conv, true);
15203 }
15204
15205 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15206         LDKCResult_BlindedRouteDecodeErrorZ* o_conv = (LDKCResult_BlindedRouteDecodeErrorZ*)untag_ptr(o);
15207         jboolean ret_conv = CResult_BlindedRouteDecodeErrorZ_is_ok(o_conv);
15208         return ret_conv;
15209 }
15210
15211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedRouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15212         if (!ptr_is_owned(_res)) return;
15213         void* _res_ptr = untag_ptr(_res);
15214         CHECK_ACCESS(_res_ptr);
15215         LDKCResult_BlindedRouteDecodeErrorZ _res_conv = *(LDKCResult_BlindedRouteDecodeErrorZ*)(_res_ptr);
15216         FREE(untag_ptr(_res));
15217         CResult_BlindedRouteDecodeErrorZ_free(_res_conv);
15218 }
15219
15220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15221         LDKBlindedHop o_conv;
15222         o_conv.inner = untag_ptr(o);
15223         o_conv.is_owned = ptr_is_owned(o);
15224         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15225         // WARNING: we need a move here but no clone is available for LDKBlindedHop
15226         
15227         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
15228         *ret_conv = CResult_BlindedHopDecodeErrorZ_ok(o_conv);
15229         return tag_ptr(ret_conv, true);
15230 }
15231
15232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15233         LDKDecodeError e_conv;
15234         e_conv.inner = untag_ptr(e);
15235         e_conv.is_owned = ptr_is_owned(e);
15236         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15237         e_conv = DecodeError_clone(&e_conv);
15238         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
15239         *ret_conv = CResult_BlindedHopDecodeErrorZ_err(e_conv);
15240         return tag_ptr(ret_conv, true);
15241 }
15242
15243 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15244         LDKCResult_BlindedHopDecodeErrorZ* o_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(o);
15245         jboolean ret_conv = CResult_BlindedHopDecodeErrorZ_is_ok(o_conv);
15246         return ret_conv;
15247 }
15248
15249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15250         if (!ptr_is_owned(_res)) return;
15251         void* _res_ptr = untag_ptr(_res);
15252         CHECK_ACCESS(_res_ptr);
15253         LDKCResult_BlindedHopDecodeErrorZ _res_conv = *(LDKCResult_BlindedHopDecodeErrorZ*)(_res_ptr);
15254         FREE(untag_ptr(_res));
15255         CResult_BlindedHopDecodeErrorZ_free(_res_conv);
15256 }
15257
15258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
15259         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15260         *ret_conv = CResult_NoneNoneZ_ok();
15261         return tag_ptr(ret_conv, true);
15262 }
15263
15264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
15265         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15266         *ret_conv = CResult_NoneNoneZ_err();
15267         return tag_ptr(ret_conv, true);
15268 }
15269
15270 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15271         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)untag_ptr(o);
15272         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
15273         return ret_conv;
15274 }
15275
15276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15277         if (!ptr_is_owned(_res)) return;
15278         void* _res_ptr = untag_ptr(_res);
15279         CHECK_ACCESS(_res_ptr);
15280         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
15281         FREE(untag_ptr(_res));
15282         CResult_NoneNoneZ_free(_res_conv);
15283 }
15284
15285 static inline uint64_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
15286         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15287         *ret_conv = CResult_NoneNoneZ_clone(arg);
15288         return tag_ptr(ret_conv, true);
15289 }
15290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15291         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)untag_ptr(arg);
15292         int64_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
15293         return ret_conv;
15294 }
15295
15296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15297         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)untag_ptr(orig);
15298         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15299         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
15300         return tag_ptr(ret_conv, true);
15301 }
15302
15303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15304         LDKCounterpartyCommitmentSecrets o_conv;
15305         o_conv.inner = untag_ptr(o);
15306         o_conv.is_owned = ptr_is_owned(o);
15307         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15308         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
15309         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
15310         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
15311         return tag_ptr(ret_conv, true);
15312 }
15313
15314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15315         LDKDecodeError e_conv;
15316         e_conv.inner = untag_ptr(e);
15317         e_conv.is_owned = ptr_is_owned(e);
15318         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15319         e_conv = DecodeError_clone(&e_conv);
15320         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
15321         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
15322         return tag_ptr(ret_conv, true);
15323 }
15324
15325 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15326         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(o);
15327         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
15328         return ret_conv;
15329 }
15330
15331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15332         if (!ptr_is_owned(_res)) return;
15333         void* _res_ptr = untag_ptr(_res);
15334         CHECK_ACCESS(_res_ptr);
15335         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
15336         FREE(untag_ptr(_res));
15337         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
15338 }
15339
15340 static inline uint64_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
15341         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
15342         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
15343         return tag_ptr(ret_conv, true);
15344 }
15345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15346         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(arg);
15347         int64_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
15348         return ret_conv;
15349 }
15350
15351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15352         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(orig);
15353         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
15354         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
15355         return tag_ptr(ret_conv, true);
15356 }
15357
15358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
15359         LDKSecretKey o_ref;
15360         CHECK((*env)->GetArrayLength(env, o) == 32);
15361         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
15362         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15363         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
15364         return tag_ptr(ret_conv, true);
15365 }
15366
15367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15368         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15369         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15370         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
15371         return tag_ptr(ret_conv, true);
15372 }
15373
15374 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15375         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(o);
15376         jboolean ret_conv = CResult_SecretKeyErrorZ_is_ok(o_conv);
15377         return ret_conv;
15378 }
15379
15380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15381         if (!ptr_is_owned(_res)) return;
15382         void* _res_ptr = untag_ptr(_res);
15383         CHECK_ACCESS(_res_ptr);
15384         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
15385         FREE(untag_ptr(_res));
15386         CResult_SecretKeyErrorZ_free(_res_conv);
15387 }
15388
15389 static inline uint64_t CResult_SecretKeyErrorZ_clone_ptr(LDKCResult_SecretKeyErrorZ *NONNULL_PTR arg) {
15390         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15391         *ret_conv = CResult_SecretKeyErrorZ_clone(arg);
15392         return tag_ptr(ret_conv, true);
15393 }
15394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15395         LDKCResult_SecretKeyErrorZ* arg_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(arg);
15396         int64_t ret_conv = CResult_SecretKeyErrorZ_clone_ptr(arg_conv);
15397         return ret_conv;
15398 }
15399
15400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15401         LDKCResult_SecretKeyErrorZ* orig_conv = (LDKCResult_SecretKeyErrorZ*)untag_ptr(orig);
15402         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
15403         *ret_conv = CResult_SecretKeyErrorZ_clone(orig_conv);
15404         return tag_ptr(ret_conv, true);
15405 }
15406
15407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
15408         LDKPublicKey o_ref;
15409         CHECK((*env)->GetArrayLength(env, o) == 33);
15410         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
15411         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15412         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
15413         return tag_ptr(ret_conv, true);
15414 }
15415
15416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15417         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15418         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15419         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
15420         return tag_ptr(ret_conv, true);
15421 }
15422
15423 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15424         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(o);
15425         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
15426         return ret_conv;
15427 }
15428
15429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15430         if (!ptr_is_owned(_res)) return;
15431         void* _res_ptr = untag_ptr(_res);
15432         CHECK_ACCESS(_res_ptr);
15433         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
15434         FREE(untag_ptr(_res));
15435         CResult_PublicKeyErrorZ_free(_res_conv);
15436 }
15437
15438 static inline uint64_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
15439         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15440         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
15441         return tag_ptr(ret_conv, true);
15442 }
15443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15444         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(arg);
15445         int64_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
15446         return ret_conv;
15447 }
15448
15449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15450         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(orig);
15451         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
15452         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
15453         return tag_ptr(ret_conv, true);
15454 }
15455
15456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15457         LDKTxCreationKeys o_conv;
15458         o_conv.inner = untag_ptr(o);
15459         o_conv.is_owned = ptr_is_owned(o);
15460         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15461         o_conv = TxCreationKeys_clone(&o_conv);
15462         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15463         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
15464         return tag_ptr(ret_conv, true);
15465 }
15466
15467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15468         LDKDecodeError e_conv;
15469         e_conv.inner = untag_ptr(e);
15470         e_conv.is_owned = ptr_is_owned(e);
15471         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15472         e_conv = DecodeError_clone(&e_conv);
15473         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15474         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
15475         return tag_ptr(ret_conv, true);
15476 }
15477
15478 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15479         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(o);
15480         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
15481         return ret_conv;
15482 }
15483
15484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15485         if (!ptr_is_owned(_res)) return;
15486         void* _res_ptr = untag_ptr(_res);
15487         CHECK_ACCESS(_res_ptr);
15488         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
15489         FREE(untag_ptr(_res));
15490         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
15491 }
15492
15493 static inline uint64_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
15494         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15495         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
15496         return tag_ptr(ret_conv, true);
15497 }
15498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15499         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(arg);
15500         int64_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
15501         return ret_conv;
15502 }
15503
15504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15505         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(orig);
15506         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
15507         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
15508         return tag_ptr(ret_conv, true);
15509 }
15510
15511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15512         LDKChannelPublicKeys o_conv;
15513         o_conv.inner = untag_ptr(o);
15514         o_conv.is_owned = ptr_is_owned(o);
15515         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15516         o_conv = ChannelPublicKeys_clone(&o_conv);
15517         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15518         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
15519         return tag_ptr(ret_conv, true);
15520 }
15521
15522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15523         LDKDecodeError e_conv;
15524         e_conv.inner = untag_ptr(e);
15525         e_conv.is_owned = ptr_is_owned(e);
15526         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15527         e_conv = DecodeError_clone(&e_conv);
15528         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15529         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
15530         return tag_ptr(ret_conv, true);
15531 }
15532
15533 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15534         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(o);
15535         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
15536         return ret_conv;
15537 }
15538
15539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15540         if (!ptr_is_owned(_res)) return;
15541         void* _res_ptr = untag_ptr(_res);
15542         CHECK_ACCESS(_res_ptr);
15543         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
15544         FREE(untag_ptr(_res));
15545         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
15546 }
15547
15548 static inline uint64_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
15549         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15550         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
15551         return tag_ptr(ret_conv, true);
15552 }
15553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15554         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(arg);
15555         int64_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
15556         return ret_conv;
15557 }
15558
15559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15560         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(orig);
15561         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
15562         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
15563         return tag_ptr(ret_conv, true);
15564 }
15565
15566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15567         LDKTxCreationKeys o_conv;
15568         o_conv.inner = untag_ptr(o);
15569         o_conv.is_owned = ptr_is_owned(o);
15570         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15571         o_conv = TxCreationKeys_clone(&o_conv);
15572         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15573         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
15574         return tag_ptr(ret_conv, true);
15575 }
15576
15577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15578         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15579         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15580         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
15581         return tag_ptr(ret_conv, true);
15582 }
15583
15584 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15585         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(o);
15586         jboolean ret_conv = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
15587         return ret_conv;
15588 }
15589
15590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15591         if (!ptr_is_owned(_res)) return;
15592         void* _res_ptr = untag_ptr(_res);
15593         CHECK_ACCESS(_res_ptr);
15594         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
15595         FREE(untag_ptr(_res));
15596         CResult_TxCreationKeysErrorZ_free(_res_conv);
15597 }
15598
15599 static inline uint64_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
15600         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15601         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
15602         return tag_ptr(ret_conv, true);
15603 }
15604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15605         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(arg);
15606         int64_t ret_conv = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
15607         return ret_conv;
15608 }
15609
15610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15611         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)untag_ptr(orig);
15612         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
15613         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
15614         return tag_ptr(ret_conv, true);
15615 }
15616
15617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
15618         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15619         *ret_copy = COption_u32Z_some(o);
15620         int64_t ret_ref = tag_ptr(ret_copy, true);
15621         return ret_ref;
15622 }
15623
15624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
15625         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15626         *ret_copy = COption_u32Z_none();
15627         int64_t ret_ref = tag_ptr(ret_copy, true);
15628         return ret_ref;
15629 }
15630
15631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
15632         if (!ptr_is_owned(_res)) return;
15633         void* _res_ptr = untag_ptr(_res);
15634         CHECK_ACCESS(_res_ptr);
15635         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
15636         FREE(untag_ptr(_res));
15637         COption_u32Z_free(_res_conv);
15638 }
15639
15640 static inline uint64_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
15641         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15642         *ret_copy = COption_u32Z_clone(arg);
15643         int64_t ret_ref = tag_ptr(ret_copy, true);
15644         return ret_ref;
15645 }
15646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15647         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)untag_ptr(arg);
15648         int64_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
15649         return ret_conv;
15650 }
15651
15652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15653         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)untag_ptr(orig);
15654         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
15655         *ret_copy = COption_u32Z_clone(orig_conv);
15656         int64_t ret_ref = tag_ptr(ret_copy, true);
15657         return ret_ref;
15658 }
15659
15660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15661         LDKHTLCOutputInCommitment o_conv;
15662         o_conv.inner = untag_ptr(o);
15663         o_conv.is_owned = ptr_is_owned(o);
15664         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15665         o_conv = HTLCOutputInCommitment_clone(&o_conv);
15666         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15667         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
15668         return tag_ptr(ret_conv, true);
15669 }
15670
15671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15672         LDKDecodeError e_conv;
15673         e_conv.inner = untag_ptr(e);
15674         e_conv.is_owned = ptr_is_owned(e);
15675         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15676         e_conv = DecodeError_clone(&e_conv);
15677         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15678         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
15679         return tag_ptr(ret_conv, true);
15680 }
15681
15682 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15683         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(o);
15684         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
15685         return ret_conv;
15686 }
15687
15688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15689         if (!ptr_is_owned(_res)) return;
15690         void* _res_ptr = untag_ptr(_res);
15691         CHECK_ACCESS(_res_ptr);
15692         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
15693         FREE(untag_ptr(_res));
15694         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
15695 }
15696
15697 static inline uint64_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
15698         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15699         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
15700         return tag_ptr(ret_conv, true);
15701 }
15702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15703         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(arg);
15704         int64_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
15705         return ret_conv;
15706 }
15707
15708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15709         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(orig);
15710         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
15711         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
15712         return tag_ptr(ret_conv, true);
15713 }
15714
15715 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1some(JNIEnv *env, jclass clz) {
15716         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_some());
15717         return ret_conv;
15718 }
15719
15720 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1none(JNIEnv *env, jclass clz) {
15721         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_none());
15722         return ret_conv;
15723 }
15724
15725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1free(JNIEnv *env, jclass clz, jclass _res) {
15726         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_java(env, _res);
15727         COption_NoneZ_free(_res_conv);
15728 }
15729
15730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15731         LDKCounterpartyChannelTransactionParameters o_conv;
15732         o_conv.inner = untag_ptr(o);
15733         o_conv.is_owned = ptr_is_owned(o);
15734         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15735         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
15736         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15737         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
15738         return tag_ptr(ret_conv, true);
15739 }
15740
15741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15742         LDKDecodeError e_conv;
15743         e_conv.inner = untag_ptr(e);
15744         e_conv.is_owned = ptr_is_owned(e);
15745         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15746         e_conv = DecodeError_clone(&e_conv);
15747         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15748         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
15749         return tag_ptr(ret_conv, true);
15750 }
15751
15752 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15753         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
15754         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
15755         return ret_conv;
15756 }
15757
15758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15759         if (!ptr_is_owned(_res)) return;
15760         void* _res_ptr = untag_ptr(_res);
15761         CHECK_ACCESS(_res_ptr);
15762         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
15763         FREE(untag_ptr(_res));
15764         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
15765 }
15766
15767 static inline uint64_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
15768         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15769         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
15770         return tag_ptr(ret_conv, true);
15771 }
15772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15773         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
15774         int64_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
15775         return ret_conv;
15776 }
15777
15778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15779         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
15780         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
15781         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
15782         return tag_ptr(ret_conv, true);
15783 }
15784
15785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15786         LDKChannelTransactionParameters o_conv;
15787         o_conv.inner = untag_ptr(o);
15788         o_conv.is_owned = ptr_is_owned(o);
15789         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15790         o_conv = ChannelTransactionParameters_clone(&o_conv);
15791         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15792         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
15793         return tag_ptr(ret_conv, true);
15794 }
15795
15796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15797         LDKDecodeError e_conv;
15798         e_conv.inner = untag_ptr(e);
15799         e_conv.is_owned = ptr_is_owned(e);
15800         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15801         e_conv = DecodeError_clone(&e_conv);
15802         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15803         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
15804         return tag_ptr(ret_conv, true);
15805 }
15806
15807 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15808         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
15809         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
15810         return ret_conv;
15811 }
15812
15813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15814         if (!ptr_is_owned(_res)) return;
15815         void* _res_ptr = untag_ptr(_res);
15816         CHECK_ACCESS(_res_ptr);
15817         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
15818         FREE(untag_ptr(_res));
15819         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
15820 }
15821
15822 static inline uint64_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
15823         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15824         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
15825         return tag_ptr(ret_conv, true);
15826 }
15827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15828         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
15829         int64_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
15830         return ret_conv;
15831 }
15832
15833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15834         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
15835         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
15836         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
15837         return tag_ptr(ret_conv, true);
15838 }
15839
15840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15841         LDKCVec_SignatureZ _res_constr;
15842         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15843         if (_res_constr.datalen > 0)
15844                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
15845         else
15846                 _res_constr.data = NULL;
15847         for (size_t i = 0; i < _res_constr.datalen; i++) {
15848                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
15849                 LDKSignature _res_conv_8_ref;
15850                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
15851                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
15852                 _res_constr.data[i] = _res_conv_8_ref;
15853         }
15854         CVec_SignatureZ_free(_res_constr);
15855 }
15856
15857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15858         LDKHolderCommitmentTransaction o_conv;
15859         o_conv.inner = untag_ptr(o);
15860         o_conv.is_owned = ptr_is_owned(o);
15861         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15862         o_conv = HolderCommitmentTransaction_clone(&o_conv);
15863         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15864         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
15865         return tag_ptr(ret_conv, true);
15866 }
15867
15868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15869         LDKDecodeError e_conv;
15870         e_conv.inner = untag_ptr(e);
15871         e_conv.is_owned = ptr_is_owned(e);
15872         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15873         e_conv = DecodeError_clone(&e_conv);
15874         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15875         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
15876         return tag_ptr(ret_conv, true);
15877 }
15878
15879 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15880         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
15881         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
15882         return ret_conv;
15883 }
15884
15885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15886         if (!ptr_is_owned(_res)) return;
15887         void* _res_ptr = untag_ptr(_res);
15888         CHECK_ACCESS(_res_ptr);
15889         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
15890         FREE(untag_ptr(_res));
15891         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
15892 }
15893
15894 static inline uint64_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
15895         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15896         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
15897         return tag_ptr(ret_conv, true);
15898 }
15899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15900         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
15901         int64_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
15902         return ret_conv;
15903 }
15904
15905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15906         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
15907         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
15908         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
15909         return tag_ptr(ret_conv, true);
15910 }
15911
15912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15913         LDKBuiltCommitmentTransaction o_conv;
15914         o_conv.inner = untag_ptr(o);
15915         o_conv.is_owned = ptr_is_owned(o);
15916         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15917         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
15918         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15919         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
15920         return tag_ptr(ret_conv, true);
15921 }
15922
15923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15924         LDKDecodeError e_conv;
15925         e_conv.inner = untag_ptr(e);
15926         e_conv.is_owned = ptr_is_owned(e);
15927         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15928         e_conv = DecodeError_clone(&e_conv);
15929         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15930         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
15931         return tag_ptr(ret_conv, true);
15932 }
15933
15934 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15935         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
15936         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
15937         return ret_conv;
15938 }
15939
15940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15941         if (!ptr_is_owned(_res)) return;
15942         void* _res_ptr = untag_ptr(_res);
15943         CHECK_ACCESS(_res_ptr);
15944         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
15945         FREE(untag_ptr(_res));
15946         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
15947 }
15948
15949 static inline uint64_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
15950         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15951         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
15952         return tag_ptr(ret_conv, true);
15953 }
15954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15955         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
15956         int64_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
15957         return ret_conv;
15958 }
15959
15960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15961         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
15962         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
15963         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
15964         return tag_ptr(ret_conv, true);
15965 }
15966
15967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15968         LDKTrustedClosingTransaction o_conv;
15969         o_conv.inner = untag_ptr(o);
15970         o_conv.is_owned = ptr_is_owned(o);
15971         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15972         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
15973         
15974         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
15975         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
15976         return tag_ptr(ret_conv, true);
15977 }
15978
15979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
15980         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
15981         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
15982         return tag_ptr(ret_conv, true);
15983 }
15984
15985 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15986         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(o);
15987         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
15988         return ret_conv;
15989 }
15990
15991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15992         if (!ptr_is_owned(_res)) return;
15993         void* _res_ptr = untag_ptr(_res);
15994         CHECK_ACCESS(_res_ptr);
15995         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
15996         FREE(untag_ptr(_res));
15997         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
15998 }
15999
16000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16001         LDKCommitmentTransaction o_conv;
16002         o_conv.inner = untag_ptr(o);
16003         o_conv.is_owned = ptr_is_owned(o);
16004         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16005         o_conv = CommitmentTransaction_clone(&o_conv);
16006         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16007         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
16008         return tag_ptr(ret_conv, true);
16009 }
16010
16011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16012         LDKDecodeError e_conv;
16013         e_conv.inner = untag_ptr(e);
16014         e_conv.is_owned = ptr_is_owned(e);
16015         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16016         e_conv = DecodeError_clone(&e_conv);
16017         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16018         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
16019         return tag_ptr(ret_conv, true);
16020 }
16021
16022 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16023         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(o);
16024         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
16025         return ret_conv;
16026 }
16027
16028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16029         if (!ptr_is_owned(_res)) return;
16030         void* _res_ptr = untag_ptr(_res);
16031         CHECK_ACCESS(_res_ptr);
16032         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
16033         FREE(untag_ptr(_res));
16034         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
16035 }
16036
16037 static inline uint64_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
16038         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16039         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
16040         return tag_ptr(ret_conv, true);
16041 }
16042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16043         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
16044         int64_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
16045         return ret_conv;
16046 }
16047
16048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16049         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
16050         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16051         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
16052         return tag_ptr(ret_conv, true);
16053 }
16054
16055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16056         LDKTrustedCommitmentTransaction o_conv;
16057         o_conv.inner = untag_ptr(o);
16058         o_conv.is_owned = ptr_is_owned(o);
16059         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16060         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
16061         
16062         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
16063         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
16064         return tag_ptr(ret_conv, true);
16065 }
16066
16067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
16068         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
16069         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
16070         return tag_ptr(ret_conv, true);
16071 }
16072
16073 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16074         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(o);
16075         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
16076         return ret_conv;
16077 }
16078
16079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16080         if (!ptr_is_owned(_res)) return;
16081         void* _res_ptr = untag_ptr(_res);
16082         CHECK_ACCESS(_res_ptr);
16083         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
16084         FREE(untag_ptr(_res));
16085         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
16086 }
16087
16088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
16089         LDKCVec_SignatureZ o_constr;
16090         o_constr.datalen = (*env)->GetArrayLength(env, o);
16091         if (o_constr.datalen > 0)
16092                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
16093         else
16094                 o_constr.data = NULL;
16095         for (size_t i = 0; i < o_constr.datalen; i++) {
16096                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
16097                 LDKSignature o_conv_8_ref;
16098                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
16099                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
16100                 o_constr.data[i] = o_conv_8_ref;
16101         }
16102         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16103         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
16104         return tag_ptr(ret_conv, true);
16105 }
16106
16107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
16108         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16109         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
16110         return tag_ptr(ret_conv, true);
16111 }
16112
16113 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16114         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(o);
16115         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
16116         return ret_conv;
16117 }
16118
16119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16120         if (!ptr_is_owned(_res)) return;
16121         void* _res_ptr = untag_ptr(_res);
16122         CHECK_ACCESS(_res_ptr);
16123         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
16124         FREE(untag_ptr(_res));
16125         CResult_CVec_SignatureZNoneZ_free(_res_conv);
16126 }
16127
16128 static inline uint64_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
16129         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16130         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
16131         return tag_ptr(ret_conv, true);
16132 }
16133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16134         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(arg);
16135         int64_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
16136         return ret_conv;
16137 }
16138
16139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16140         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(orig);
16141         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16142         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
16143         return tag_ptr(ret_conv, true);
16144 }
16145
16146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16147         LDKShutdownScript o_conv;
16148         o_conv.inner = untag_ptr(o);
16149         o_conv.is_owned = ptr_is_owned(o);
16150         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16151         o_conv = ShutdownScript_clone(&o_conv);
16152         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16153         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
16154         return tag_ptr(ret_conv, true);
16155 }
16156
16157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16158         LDKDecodeError e_conv;
16159         e_conv.inner = untag_ptr(e);
16160         e_conv.is_owned = ptr_is_owned(e);
16161         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16162         e_conv = DecodeError_clone(&e_conv);
16163         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16164         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
16165         return tag_ptr(ret_conv, true);
16166 }
16167
16168 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16169         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(o);
16170         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
16171         return ret_conv;
16172 }
16173
16174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16175         if (!ptr_is_owned(_res)) return;
16176         void* _res_ptr = untag_ptr(_res);
16177         CHECK_ACCESS(_res_ptr);
16178         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
16179         FREE(untag_ptr(_res));
16180         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
16181 }
16182
16183 static inline uint64_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
16184         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16185         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
16186         return tag_ptr(ret_conv, true);
16187 }
16188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16189         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(arg);
16190         int64_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
16191         return ret_conv;
16192 }
16193
16194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16195         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(orig);
16196         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16197         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
16198         return tag_ptr(ret_conv, true);
16199 }
16200
16201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16202         LDKShutdownScript o_conv;
16203         o_conv.inner = untag_ptr(o);
16204         o_conv.is_owned = ptr_is_owned(o);
16205         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16206         o_conv = ShutdownScript_clone(&o_conv);
16207         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16208         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
16209         return tag_ptr(ret_conv, true);
16210 }
16211
16212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16213         LDKInvalidShutdownScript e_conv;
16214         e_conv.inner = untag_ptr(e);
16215         e_conv.is_owned = ptr_is_owned(e);
16216         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16217         e_conv = InvalidShutdownScript_clone(&e_conv);
16218         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16219         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
16220         return tag_ptr(ret_conv, true);
16221 }
16222
16223 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16224         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(o);
16225         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
16226         return ret_conv;
16227 }
16228
16229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16230         if (!ptr_is_owned(_res)) return;
16231         void* _res_ptr = untag_ptr(_res);
16232         CHECK_ACCESS(_res_ptr);
16233         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
16234         FREE(untag_ptr(_res));
16235         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
16236 }
16237
16238 static inline uint64_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
16239         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16240         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
16241         return tag_ptr(ret_conv, true);
16242 }
16243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16244         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(arg);
16245         int64_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
16246         return ret_conv;
16247 }
16248
16249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16250         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(orig);
16251         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16252         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
16253         return tag_ptr(ret_conv, true);
16254 }
16255
16256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16257         void* o_ptr = untag_ptr(o);
16258         CHECK_ACCESS(o_ptr);
16259         LDKWriteableScore o_conv = *(LDKWriteableScore*)(o_ptr);
16260         if (o_conv.free == LDKWriteableScore_JCalls_free) {
16261                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16262                 LDKWriteableScore_JCalls_cloned(&o_conv);
16263         }
16264         LDKCOption_WriteableScoreZ *ret_copy = MALLOC(sizeof(LDKCOption_WriteableScoreZ), "LDKCOption_WriteableScoreZ");
16265         *ret_copy = COption_WriteableScoreZ_some(o_conv);
16266         int64_t ret_ref = tag_ptr(ret_copy, true);
16267         return ret_ref;
16268 }
16269
16270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1none(JNIEnv *env, jclass clz) {
16271         LDKCOption_WriteableScoreZ *ret_copy = MALLOC(sizeof(LDKCOption_WriteableScoreZ), "LDKCOption_WriteableScoreZ");
16272         *ret_copy = COption_WriteableScoreZ_none();
16273         int64_t ret_ref = tag_ptr(ret_copy, true);
16274         return ret_ref;
16275 }
16276
16277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16278         if (!ptr_is_owned(_res)) return;
16279         void* _res_ptr = untag_ptr(_res);
16280         CHECK_ACCESS(_res_ptr);
16281         LDKCOption_WriteableScoreZ _res_conv = *(LDKCOption_WriteableScoreZ*)(_res_ptr);
16282         FREE(untag_ptr(_res));
16283         COption_WriteableScoreZ_free(_res_conv);
16284 }
16285
16286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
16287         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
16288         *ret_conv = CResult_NoneErrorZ_ok();
16289         return tag_ptr(ret_conv, true);
16290 }
16291
16292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
16293         LDKIOError e_conv = LDKIOError_from_java(env, e);
16294         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
16295         *ret_conv = CResult_NoneErrorZ_err(e_conv);
16296         return tag_ptr(ret_conv, true);
16297 }
16298
16299 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16300         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)untag_ptr(o);
16301         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
16302         return ret_conv;
16303 }
16304
16305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16306         if (!ptr_is_owned(_res)) return;
16307         void* _res_ptr = untag_ptr(_res);
16308         CHECK_ACCESS(_res_ptr);
16309         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
16310         FREE(untag_ptr(_res));
16311         CResult_NoneErrorZ_free(_res_conv);
16312 }
16313
16314 static inline uint64_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
16315         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
16316         *ret_conv = CResult_NoneErrorZ_clone(arg);
16317         return tag_ptr(ret_conv, true);
16318 }
16319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16320         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)untag_ptr(arg);
16321         int64_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
16322         return ret_conv;
16323 }
16324
16325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16326         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)untag_ptr(orig);
16327         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
16328         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
16329         return tag_ptr(ret_conv, true);
16330 }
16331
16332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16333         LDKRouteHop o_conv;
16334         o_conv.inner = untag_ptr(o);
16335         o_conv.is_owned = ptr_is_owned(o);
16336         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16337         o_conv = RouteHop_clone(&o_conv);
16338         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
16339         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
16340         return tag_ptr(ret_conv, true);
16341 }
16342
16343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16344         LDKDecodeError e_conv;
16345         e_conv.inner = untag_ptr(e);
16346         e_conv.is_owned = ptr_is_owned(e);
16347         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16348         e_conv = DecodeError_clone(&e_conv);
16349         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
16350         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
16351         return tag_ptr(ret_conv, true);
16352 }
16353
16354 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16355         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(o);
16356         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
16357         return ret_conv;
16358 }
16359
16360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16361         if (!ptr_is_owned(_res)) return;
16362         void* _res_ptr = untag_ptr(_res);
16363         CHECK_ACCESS(_res_ptr);
16364         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
16365         FREE(untag_ptr(_res));
16366         CResult_RouteHopDecodeErrorZ_free(_res_conv);
16367 }
16368
16369 static inline uint64_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
16370         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
16371         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
16372         return tag_ptr(ret_conv, true);
16373 }
16374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16375         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(arg);
16376         int64_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
16377         return ret_conv;
16378 }
16379
16380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16381         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(orig);
16382         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
16383         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
16384         return tag_ptr(ret_conv, true);
16385 }
16386
16387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16388         LDKCVec_RouteHopZ _res_constr;
16389         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16390         if (_res_constr.datalen > 0)
16391                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
16392         else
16393                 _res_constr.data = NULL;
16394         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16395         for (size_t k = 0; k < _res_constr.datalen; k++) {
16396                 int64_t _res_conv_10 = _res_vals[k];
16397                 LDKRouteHop _res_conv_10_conv;
16398                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
16399                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
16400                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
16401                 _res_constr.data[k] = _res_conv_10_conv;
16402         }
16403         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16404         CVec_RouteHopZ_free(_res_constr);
16405 }
16406
16407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16408         LDKCVec_CVec_RouteHopZZ _res_constr;
16409         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16410         if (_res_constr.datalen > 0)
16411                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
16412         else
16413                 _res_constr.data = NULL;
16414         for (size_t m = 0; m < _res_constr.datalen; m++) {
16415                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
16416                 LDKCVec_RouteHopZ _res_conv_12_constr;
16417                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
16418                 if (_res_conv_12_constr.datalen > 0)
16419                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
16420                 else
16421                         _res_conv_12_constr.data = NULL;
16422                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
16423                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
16424                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
16425                         LDKRouteHop _res_conv_12_conv_10_conv;
16426                         _res_conv_12_conv_10_conv.inner = untag_ptr(_res_conv_12_conv_10);
16427                         _res_conv_12_conv_10_conv.is_owned = ptr_is_owned(_res_conv_12_conv_10);
16428                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
16429                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
16430                 }
16431                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
16432                 _res_constr.data[m] = _res_conv_12_constr;
16433         }
16434         CVec_CVec_RouteHopZZ_free(_res_constr);
16435 }
16436
16437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16438         LDKRoute o_conv;
16439         o_conv.inner = untag_ptr(o);
16440         o_conv.is_owned = ptr_is_owned(o);
16441         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16442         o_conv = Route_clone(&o_conv);
16443         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16444         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
16445         return tag_ptr(ret_conv, true);
16446 }
16447
16448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16449         LDKDecodeError e_conv;
16450         e_conv.inner = untag_ptr(e);
16451         e_conv.is_owned = ptr_is_owned(e);
16452         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16453         e_conv = DecodeError_clone(&e_conv);
16454         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16455         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
16456         return tag_ptr(ret_conv, true);
16457 }
16458
16459 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16460         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(o);
16461         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
16462         return ret_conv;
16463 }
16464
16465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16466         if (!ptr_is_owned(_res)) return;
16467         void* _res_ptr = untag_ptr(_res);
16468         CHECK_ACCESS(_res_ptr);
16469         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
16470         FREE(untag_ptr(_res));
16471         CResult_RouteDecodeErrorZ_free(_res_conv);
16472 }
16473
16474 static inline uint64_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
16475         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16476         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
16477         return tag_ptr(ret_conv, true);
16478 }
16479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16480         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(arg);
16481         int64_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
16482         return ret_conv;
16483 }
16484
16485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16486         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(orig);
16487         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
16488         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
16489         return tag_ptr(ret_conv, true);
16490 }
16491
16492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16493         LDKRouteParameters o_conv;
16494         o_conv.inner = untag_ptr(o);
16495         o_conv.is_owned = ptr_is_owned(o);
16496         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16497         o_conv = RouteParameters_clone(&o_conv);
16498         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16499         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
16500         return tag_ptr(ret_conv, true);
16501 }
16502
16503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16504         LDKDecodeError e_conv;
16505         e_conv.inner = untag_ptr(e);
16506         e_conv.is_owned = ptr_is_owned(e);
16507         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16508         e_conv = DecodeError_clone(&e_conv);
16509         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16510         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
16511         return tag_ptr(ret_conv, true);
16512 }
16513
16514 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16515         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(o);
16516         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
16517         return ret_conv;
16518 }
16519
16520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16521         if (!ptr_is_owned(_res)) return;
16522         void* _res_ptr = untag_ptr(_res);
16523         CHECK_ACCESS(_res_ptr);
16524         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
16525         FREE(untag_ptr(_res));
16526         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
16527 }
16528
16529 static inline uint64_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
16530         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16531         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
16532         return tag_ptr(ret_conv, true);
16533 }
16534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16535         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(arg);
16536         int64_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
16537         return ret_conv;
16538 }
16539
16540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16541         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(orig);
16542         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
16543         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
16544         return tag_ptr(ret_conv, true);
16545 }
16546
16547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16548         LDKCVec_RouteHintZ _res_constr;
16549         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16550         if (_res_constr.datalen > 0)
16551                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
16552         else
16553                 _res_constr.data = NULL;
16554         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16555         for (size_t l = 0; l < _res_constr.datalen; l++) {
16556                 int64_t _res_conv_11 = _res_vals[l];
16557                 LDKRouteHint _res_conv_11_conv;
16558                 _res_conv_11_conv.inner = untag_ptr(_res_conv_11);
16559                 _res_conv_11_conv.is_owned = ptr_is_owned(_res_conv_11);
16560                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
16561                 _res_constr.data[l] = _res_conv_11_conv;
16562         }
16563         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16564         CVec_RouteHintZ_free(_res_constr);
16565 }
16566
16567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
16568         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16569         *ret_copy = COption_u64Z_some(o);
16570         int64_t ret_ref = tag_ptr(ret_copy, true);
16571         return ret_ref;
16572 }
16573
16574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
16575         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16576         *ret_copy = COption_u64Z_none();
16577         int64_t ret_ref = tag_ptr(ret_copy, true);
16578         return ret_ref;
16579 }
16580
16581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
16582         if (!ptr_is_owned(_res)) return;
16583         void* _res_ptr = untag_ptr(_res);
16584         CHECK_ACCESS(_res_ptr);
16585         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
16586         FREE(untag_ptr(_res));
16587         COption_u64Z_free(_res_conv);
16588 }
16589
16590 static inline uint64_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
16591         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16592         *ret_copy = COption_u64Z_clone(arg);
16593         int64_t ret_ref = tag_ptr(ret_copy, true);
16594         return ret_ref;
16595 }
16596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16597         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)untag_ptr(arg);
16598         int64_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
16599         return ret_conv;
16600 }
16601
16602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16603         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)untag_ptr(orig);
16604         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
16605         *ret_copy = COption_u64Z_clone(orig_conv);
16606         int64_t ret_ref = tag_ptr(ret_copy, true);
16607         return ret_ref;
16608 }
16609
16610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16611         LDKCVec_u64Z _res_constr;
16612         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16613         if (_res_constr.datalen > 0)
16614                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16615         else
16616                 _res_constr.data = NULL;
16617         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16618         for (size_t g = 0; g < _res_constr.datalen; g++) {
16619                 int64_t _res_conv_6 = _res_vals[g];
16620                 _res_constr.data[g] = _res_conv_6;
16621         }
16622         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16623         CVec_u64Z_free(_res_constr);
16624 }
16625
16626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16627         LDKPaymentParameters o_conv;
16628         o_conv.inner = untag_ptr(o);
16629         o_conv.is_owned = ptr_is_owned(o);
16630         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16631         o_conv = PaymentParameters_clone(&o_conv);
16632         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16633         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
16634         return tag_ptr(ret_conv, true);
16635 }
16636
16637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16638         LDKDecodeError e_conv;
16639         e_conv.inner = untag_ptr(e);
16640         e_conv.is_owned = ptr_is_owned(e);
16641         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16642         e_conv = DecodeError_clone(&e_conv);
16643         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16644         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
16645         return tag_ptr(ret_conv, true);
16646 }
16647
16648 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16649         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(o);
16650         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
16651         return ret_conv;
16652 }
16653
16654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16655         if (!ptr_is_owned(_res)) return;
16656         void* _res_ptr = untag_ptr(_res);
16657         CHECK_ACCESS(_res_ptr);
16658         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
16659         FREE(untag_ptr(_res));
16660         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
16661 }
16662
16663 static inline uint64_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
16664         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16665         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
16666         return tag_ptr(ret_conv, true);
16667 }
16668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16669         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(arg);
16670         int64_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
16671         return ret_conv;
16672 }
16673
16674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16675         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(orig);
16676         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
16677         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
16678         return tag_ptr(ret_conv, true);
16679 }
16680
16681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16682         LDKCVec_RouteHintHopZ _res_constr;
16683         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16684         if (_res_constr.datalen > 0)
16685                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
16686         else
16687                 _res_constr.data = NULL;
16688         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16689         for (size_t o = 0; o < _res_constr.datalen; o++) {
16690                 int64_t _res_conv_14 = _res_vals[o];
16691                 LDKRouteHintHop _res_conv_14_conv;
16692                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
16693                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
16694                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
16695                 _res_constr.data[o] = _res_conv_14_conv;
16696         }
16697         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16698         CVec_RouteHintHopZ_free(_res_constr);
16699 }
16700
16701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16702         LDKRouteHint o_conv;
16703         o_conv.inner = untag_ptr(o);
16704         o_conv.is_owned = ptr_is_owned(o);
16705         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16706         o_conv = RouteHint_clone(&o_conv);
16707         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
16708         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
16709         return tag_ptr(ret_conv, true);
16710 }
16711
16712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16713         LDKDecodeError e_conv;
16714         e_conv.inner = untag_ptr(e);
16715         e_conv.is_owned = ptr_is_owned(e);
16716         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16717         e_conv = DecodeError_clone(&e_conv);
16718         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
16719         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
16720         return tag_ptr(ret_conv, true);
16721 }
16722
16723 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16724         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(o);
16725         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
16726         return ret_conv;
16727 }
16728
16729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16730         if (!ptr_is_owned(_res)) return;
16731         void* _res_ptr = untag_ptr(_res);
16732         CHECK_ACCESS(_res_ptr);
16733         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
16734         FREE(untag_ptr(_res));
16735         CResult_RouteHintDecodeErrorZ_free(_res_conv);
16736 }
16737
16738 static inline uint64_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
16739         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
16740         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
16741         return tag_ptr(ret_conv, true);
16742 }
16743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16744         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(arg);
16745         int64_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
16746         return ret_conv;
16747 }
16748
16749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16750         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(orig);
16751         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
16752         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
16753         return tag_ptr(ret_conv, true);
16754 }
16755
16756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16757         LDKRouteHintHop o_conv;
16758         o_conv.inner = untag_ptr(o);
16759         o_conv.is_owned = ptr_is_owned(o);
16760         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16761         o_conv = RouteHintHop_clone(&o_conv);
16762         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16763         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
16764         return tag_ptr(ret_conv, true);
16765 }
16766
16767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16768         LDKDecodeError e_conv;
16769         e_conv.inner = untag_ptr(e);
16770         e_conv.is_owned = ptr_is_owned(e);
16771         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16772         e_conv = DecodeError_clone(&e_conv);
16773         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16774         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
16775         return tag_ptr(ret_conv, true);
16776 }
16777
16778 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16779         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(o);
16780         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
16781         return ret_conv;
16782 }
16783
16784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16785         if (!ptr_is_owned(_res)) return;
16786         void* _res_ptr = untag_ptr(_res);
16787         CHECK_ACCESS(_res_ptr);
16788         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
16789         FREE(untag_ptr(_res));
16790         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
16791 }
16792
16793 static inline uint64_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
16794         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16795         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
16796         return tag_ptr(ret_conv, true);
16797 }
16798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16799         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(arg);
16800         int64_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
16801         return ret_conv;
16802 }
16803
16804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16805         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(orig);
16806         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
16807         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
16808         return tag_ptr(ret_conv, true);
16809 }
16810
16811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16812         LDKCVec_ChannelDetailsZ _res_constr;
16813         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16814         if (_res_constr.datalen > 0)
16815                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
16816         else
16817                 _res_constr.data = NULL;
16818         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16819         for (size_t q = 0; q < _res_constr.datalen; q++) {
16820                 int64_t _res_conv_16 = _res_vals[q];
16821                 LDKChannelDetails _res_conv_16_conv;
16822                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
16823                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
16824                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
16825                 _res_constr.data[q] = _res_conv_16_conv;
16826         }
16827         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16828         CVec_ChannelDetailsZ_free(_res_constr);
16829 }
16830
16831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16832         LDKRoute o_conv;
16833         o_conv.inner = untag_ptr(o);
16834         o_conv.is_owned = ptr_is_owned(o);
16835         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16836         o_conv = Route_clone(&o_conv);
16837         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16838         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
16839         return tag_ptr(ret_conv, true);
16840 }
16841
16842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16843         LDKLightningError e_conv;
16844         e_conv.inner = untag_ptr(e);
16845         e_conv.is_owned = ptr_is_owned(e);
16846         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16847         e_conv = LightningError_clone(&e_conv);
16848         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16849         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
16850         return tag_ptr(ret_conv, true);
16851 }
16852
16853 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16854         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(o);
16855         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
16856         return ret_conv;
16857 }
16858
16859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16860         if (!ptr_is_owned(_res)) return;
16861         void* _res_ptr = untag_ptr(_res);
16862         CHECK_ACCESS(_res_ptr);
16863         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
16864         FREE(untag_ptr(_res));
16865         CResult_RouteLightningErrorZ_free(_res_conv);
16866 }
16867
16868 static inline uint64_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
16869         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16870         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
16871         return tag_ptr(ret_conv, true);
16872 }
16873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16874         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(arg);
16875         int64_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
16876         return ret_conv;
16877 }
16878
16879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16880         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(orig);
16881         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
16882         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
16883         return tag_ptr(ret_conv, true);
16884 }
16885
16886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16887         void* o_ptr = untag_ptr(o);
16888         CHECK_ACCESS(o_ptr);
16889         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
16890         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(o));
16891         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16892         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
16893         return tag_ptr(ret_conv, true);
16894 }
16895
16896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16897         LDKDecodeError e_conv;
16898         e_conv.inner = untag_ptr(e);
16899         e_conv.is_owned = ptr_is_owned(e);
16900         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16901         e_conv = DecodeError_clone(&e_conv);
16902         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16903         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
16904         return tag_ptr(ret_conv, true);
16905 }
16906
16907 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16908         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(o);
16909         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
16910         return ret_conv;
16911 }
16912
16913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16914         if (!ptr_is_owned(_res)) return;
16915         void* _res_ptr = untag_ptr(_res);
16916         CHECK_ACCESS(_res_ptr);
16917         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
16918         FREE(untag_ptr(_res));
16919         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
16920 }
16921
16922 static inline uint64_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
16923         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16924         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
16925         return tag_ptr(ret_conv, true);
16926 }
16927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16928         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(arg);
16929         int64_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
16930         return ret_conv;
16931 }
16932
16933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16934         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(orig);
16935         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
16936         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
16937         return tag_ptr(ret_conv, true);
16938 }
16939
16940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16941         void* o_ptr = untag_ptr(o);
16942         CHECK_ACCESS(o_ptr);
16943         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
16944         o_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(o));
16945         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16946         *ret_copy = COption_ClosureReasonZ_some(o_conv);
16947         int64_t ret_ref = tag_ptr(ret_copy, true);
16948         return ret_ref;
16949 }
16950
16951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
16952         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16953         *ret_copy = COption_ClosureReasonZ_none();
16954         int64_t ret_ref = tag_ptr(ret_copy, true);
16955         return ret_ref;
16956 }
16957
16958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16959         if (!ptr_is_owned(_res)) return;
16960         void* _res_ptr = untag_ptr(_res);
16961         CHECK_ACCESS(_res_ptr);
16962         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
16963         FREE(untag_ptr(_res));
16964         COption_ClosureReasonZ_free(_res_conv);
16965 }
16966
16967 static inline uint64_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
16968         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16969         *ret_copy = COption_ClosureReasonZ_clone(arg);
16970         int64_t ret_ref = tag_ptr(ret_copy, true);
16971         return ret_ref;
16972 }
16973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16974         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(arg);
16975         int64_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
16976         return ret_conv;
16977 }
16978
16979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16980         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(orig);
16981         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
16982         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
16983         int64_t ret_ref = tag_ptr(ret_copy, true);
16984         return ret_ref;
16985 }
16986
16987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16988         void* o_ptr = untag_ptr(o);
16989         CHECK_ACCESS(o_ptr);
16990         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
16991         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)untag_ptr(o));
16992         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
16993         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
16994         return tag_ptr(ret_conv, true);
16995 }
16996
16997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16998         LDKDecodeError e_conv;
16999         e_conv.inner = untag_ptr(e);
17000         e_conv.is_owned = ptr_is_owned(e);
17001         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17002         e_conv = DecodeError_clone(&e_conv);
17003         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17004         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
17005         return tag_ptr(ret_conv, true);
17006 }
17007
17008 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17009         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(o);
17010         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
17011         return ret_conv;
17012 }
17013
17014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17015         if (!ptr_is_owned(_res)) return;
17016         void* _res_ptr = untag_ptr(_res);
17017         CHECK_ACCESS(_res_ptr);
17018         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
17019         FREE(untag_ptr(_res));
17020         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
17021 }
17022
17023 static inline uint64_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
17024         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17025         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
17026         return tag_ptr(ret_conv, true);
17027 }
17028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17029         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(arg);
17030         int64_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
17031         return ret_conv;
17032 }
17033
17034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17035         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(orig);
17036         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17037         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
17038         return tag_ptr(ret_conv, true);
17039 }
17040
17041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17042         void* o_ptr = untag_ptr(o);
17043         CHECK_ACCESS(o_ptr);
17044         LDKHTLCDestination o_conv = *(LDKHTLCDestination*)(o_ptr);
17045         o_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(o));
17046         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17047         *ret_copy = COption_HTLCDestinationZ_some(o_conv);
17048         int64_t ret_ref = tag_ptr(ret_copy, true);
17049         return ret_ref;
17050 }
17051
17052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1none(JNIEnv *env, jclass clz) {
17053         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17054         *ret_copy = COption_HTLCDestinationZ_none();
17055         int64_t ret_ref = tag_ptr(ret_copy, true);
17056         return ret_ref;
17057 }
17058
17059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17060         if (!ptr_is_owned(_res)) return;
17061         void* _res_ptr = untag_ptr(_res);
17062         CHECK_ACCESS(_res_ptr);
17063         LDKCOption_HTLCDestinationZ _res_conv = *(LDKCOption_HTLCDestinationZ*)(_res_ptr);
17064         FREE(untag_ptr(_res));
17065         COption_HTLCDestinationZ_free(_res_conv);
17066 }
17067
17068 static inline uint64_t COption_HTLCDestinationZ_clone_ptr(LDKCOption_HTLCDestinationZ *NONNULL_PTR arg) {
17069         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17070         *ret_copy = COption_HTLCDestinationZ_clone(arg);
17071         int64_t ret_ref = tag_ptr(ret_copy, true);
17072         return ret_ref;
17073 }
17074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17075         LDKCOption_HTLCDestinationZ* arg_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(arg);
17076         int64_t ret_conv = COption_HTLCDestinationZ_clone_ptr(arg_conv);
17077         return ret_conv;
17078 }
17079
17080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17081         LDKCOption_HTLCDestinationZ* orig_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(orig);
17082         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17083         *ret_copy = COption_HTLCDestinationZ_clone(orig_conv);
17084         int64_t ret_ref = tag_ptr(ret_copy, true);
17085         return ret_ref;
17086 }
17087
17088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17089         void* o_ptr = untag_ptr(o);
17090         CHECK_ACCESS(o_ptr);
17091         LDKCOption_HTLCDestinationZ o_conv = *(LDKCOption_HTLCDestinationZ*)(o_ptr);
17092         o_conv = COption_HTLCDestinationZ_clone((LDKCOption_HTLCDestinationZ*)untag_ptr(o));
17093         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
17094         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o_conv);
17095         return tag_ptr(ret_conv, true);
17096 }
17097
17098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17099         LDKDecodeError e_conv;
17100         e_conv.inner = untag_ptr(e);
17101         e_conv.is_owned = ptr_is_owned(e);
17102         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17103         e_conv = DecodeError_clone(&e_conv);
17104         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
17105         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_err(e_conv);
17106         return tag_ptr(ret_conv, true);
17107 }
17108
17109 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17110         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* o_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(o);
17111         jboolean ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o_conv);
17112         return ret_conv;
17113 }
17114
17115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17116         if (!ptr_is_owned(_res)) return;
17117         void* _res_ptr = untag_ptr(_res);
17118         CHECK_ACCESS(_res_ptr);
17119         LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res_conv = *(LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(_res_ptr);
17120         FREE(untag_ptr(_res));
17121         CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res_conv);
17122 }
17123
17124 static inline uint64_t CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR arg) {
17125         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
17126         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(arg);
17127         return tag_ptr(ret_conv, true);
17128 }
17129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17130         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* arg_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(arg);
17131         int64_t ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(arg_conv);
17132         return ret_conv;
17133 }
17134
17135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17136         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* orig_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(orig);
17137         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
17138         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig_conv);
17139         return tag_ptr(ret_conv, true);
17140 }
17141
17142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17143         void* o_ptr = untag_ptr(o);
17144         CHECK_ACCESS(o_ptr);
17145         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
17146         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)untag_ptr(o));
17147         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17148         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
17149         int64_t ret_ref = tag_ptr(ret_copy, true);
17150         return ret_ref;
17151 }
17152
17153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
17154         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17155         *ret_copy = COption_NetworkUpdateZ_none();
17156         int64_t ret_ref = tag_ptr(ret_copy, true);
17157         return ret_ref;
17158 }
17159
17160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17161         if (!ptr_is_owned(_res)) return;
17162         void* _res_ptr = untag_ptr(_res);
17163         CHECK_ACCESS(_res_ptr);
17164         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
17165         FREE(untag_ptr(_res));
17166         COption_NetworkUpdateZ_free(_res_conv);
17167 }
17168
17169 static inline uint64_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
17170         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17171         *ret_copy = COption_NetworkUpdateZ_clone(arg);
17172         int64_t ret_ref = tag_ptr(ret_copy, true);
17173         return ret_ref;
17174 }
17175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17176         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(arg);
17177         int64_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
17178         return ret_conv;
17179 }
17180
17181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17182         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(orig);
17183         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17184         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
17185         int64_t ret_ref = tag_ptr(ret_copy, true);
17186         return ret_ref;
17187 }
17188
17189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17190         LDKCVec_SpendableOutputDescriptorZ _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(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
17194         else
17195                 _res_constr.data = NULL;
17196         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17197         for (size_t b = 0; b < _res_constr.datalen; b++) {
17198                 int64_t _res_conv_27 = _res_vals[b];
17199                 void* _res_conv_27_ptr = untag_ptr(_res_conv_27);
17200                 CHECK_ACCESS(_res_conv_27_ptr);
17201                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
17202                 FREE(untag_ptr(_res_conv_27));
17203                 _res_constr.data[b] = _res_conv_27_conv;
17204         }
17205         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17206         CVec_SpendableOutputDescriptorZ_free(_res_constr);
17207 }
17208
17209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17210         void* o_ptr = untag_ptr(o);
17211         CHECK_ACCESS(o_ptr);
17212         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
17213         o_conv = Event_clone((LDKEvent*)untag_ptr(o));
17214         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
17215         *ret_copy = COption_EventZ_some(o_conv);
17216         int64_t ret_ref = tag_ptr(ret_copy, true);
17217         return ret_ref;
17218 }
17219
17220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
17221         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
17222         *ret_copy = COption_EventZ_none();
17223         int64_t ret_ref = tag_ptr(ret_copy, true);
17224         return ret_ref;
17225 }
17226
17227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17228         if (!ptr_is_owned(_res)) return;
17229         void* _res_ptr = untag_ptr(_res);
17230         CHECK_ACCESS(_res_ptr);
17231         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
17232         FREE(untag_ptr(_res));
17233         COption_EventZ_free(_res_conv);
17234 }
17235
17236 static inline uint64_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
17237         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
17238         *ret_copy = COption_EventZ_clone(arg);
17239         int64_t ret_ref = tag_ptr(ret_copy, true);
17240         return ret_ref;
17241 }
17242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17243         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)untag_ptr(arg);
17244         int64_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
17245         return ret_conv;
17246 }
17247
17248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17249         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)untag_ptr(orig);
17250         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
17251         *ret_copy = COption_EventZ_clone(orig_conv);
17252         int64_t ret_ref = tag_ptr(ret_copy, true);
17253         return ret_ref;
17254 }
17255
17256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17257         void* o_ptr = untag_ptr(o);
17258         CHECK_ACCESS(o_ptr);
17259         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
17260         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)untag_ptr(o));
17261         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
17262         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
17263         return tag_ptr(ret_conv, true);
17264 }
17265
17266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17267         LDKDecodeError e_conv;
17268         e_conv.inner = untag_ptr(e);
17269         e_conv.is_owned = ptr_is_owned(e);
17270         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17271         e_conv = DecodeError_clone(&e_conv);
17272         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
17273         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
17274         return tag_ptr(ret_conv, true);
17275 }
17276
17277 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17278         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(o);
17279         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
17280         return ret_conv;
17281 }
17282
17283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17284         if (!ptr_is_owned(_res)) return;
17285         void* _res_ptr = untag_ptr(_res);
17286         CHECK_ACCESS(_res_ptr);
17287         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
17288         FREE(untag_ptr(_res));
17289         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
17290 }
17291
17292 static inline uint64_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
17293         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
17294         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
17295         return tag_ptr(ret_conv, true);
17296 }
17297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17298         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(arg);
17299         int64_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
17300         return ret_conv;
17301 }
17302
17303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17304         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(orig);
17305         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
17306         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
17307         return tag_ptr(ret_conv, true);
17308 }
17309
17310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17311         LDKCVec_MessageSendEventZ _res_constr;
17312         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17313         if (_res_constr.datalen > 0)
17314                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
17315         else
17316                 _res_constr.data = NULL;
17317         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17318         for (size_t s = 0; s < _res_constr.datalen; s++) {
17319                 int64_t _res_conv_18 = _res_vals[s];
17320                 void* _res_conv_18_ptr = untag_ptr(_res_conv_18);
17321                 CHECK_ACCESS(_res_conv_18_ptr);
17322                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
17323                 FREE(untag_ptr(_res_conv_18));
17324                 _res_constr.data[s] = _res_conv_18_conv;
17325         }
17326         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17327         CVec_MessageSendEventZ_free(_res_constr);
17328 }
17329
17330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17331         void* o_ptr = untag_ptr(o);
17332         CHECK_ACCESS(o_ptr);
17333         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
17334         o_conv = TxOut_clone((LDKTxOut*)untag_ptr(o));
17335         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
17336         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
17337         return tag_ptr(ret_conv, true);
17338 }
17339
17340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
17341         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
17342         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
17343         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
17344         return tag_ptr(ret_conv, true);
17345 }
17346
17347 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17348         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(o);
17349         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
17350         return ret_conv;
17351 }
17352
17353 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17354         if (!ptr_is_owned(_res)) return;
17355         void* _res_ptr = untag_ptr(_res);
17356         CHECK_ACCESS(_res_ptr);
17357         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
17358         FREE(untag_ptr(_res));
17359         CResult_TxOutAccessErrorZ_free(_res_conv);
17360 }
17361
17362 static inline uint64_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
17363         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
17364         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
17365         return tag_ptr(ret_conv, true);
17366 }
17367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17368         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(arg);
17369         int64_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
17370         return ret_conv;
17371 }
17372
17373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17374         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(orig);
17375         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
17376         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
17377         return tag_ptr(ret_conv, true);
17378 }
17379
17380 static inline uint64_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
17381         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
17382         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
17383         return tag_ptr(ret_conv, true);
17384 }
17385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17386         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(arg);
17387         int64_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
17388         return ret_conv;
17389 }
17390
17391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17392         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(orig);
17393         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
17394         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
17395         return tag_ptr(ret_conv, true);
17396 }
17397
17398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
17399         LDKTransaction b_ref;
17400         b_ref.datalen = (*env)->GetArrayLength(env, b);
17401         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
17402         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
17403         b_ref.data_is_owned = true;
17404         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
17405         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
17406         return tag_ptr(ret_conv, true);
17407 }
17408
17409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17410         if (!ptr_is_owned(_res)) return;
17411         void* _res_ptr = untag_ptr(_res);
17412         CHECK_ACCESS(_res_ptr);
17413         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
17414         FREE(untag_ptr(_res));
17415         C2Tuple_usizeTransactionZ_free(_res_conv);
17416 }
17417
17418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17419         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
17420         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17421         if (_res_constr.datalen > 0)
17422                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
17423         else
17424                 _res_constr.data = NULL;
17425         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17426         for (size_t c = 0; c < _res_constr.datalen; c++) {
17427                 int64_t _res_conv_28 = _res_vals[c];
17428                 void* _res_conv_28_ptr = untag_ptr(_res_conv_28);
17429                 CHECK_ACCESS(_res_conv_28_ptr);
17430                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
17431                 FREE(untag_ptr(_res_conv_28));
17432                 _res_constr.data[c] = _res_conv_28_conv;
17433         }
17434         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17435         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
17436 }
17437
17438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
17439         LDKCVec_TxidZ _res_constr;
17440         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17441         if (_res_constr.datalen > 0)
17442                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
17443         else
17444                 _res_constr.data = NULL;
17445         for (size_t i = 0; i < _res_constr.datalen; i++) {
17446                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
17447                 LDKThirtyTwoBytes _res_conv_8_ref;
17448                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
17449                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
17450                 _res_constr.data[i] = _res_conv_8_ref;
17451         }
17452         CVec_TxidZ_free(_res_constr);
17453 }
17454
17455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
17456         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
17457         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
17458         return tag_ptr(ret_conv, true);
17459 }
17460
17461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
17462         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
17463         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
17464         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
17465         return tag_ptr(ret_conv, true);
17466 }
17467
17468 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17469         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)untag_ptr(o);
17470         jboolean ret_conv = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
17471         return ret_conv;
17472 }
17473
17474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17475         if (!ptr_is_owned(_res)) return;
17476         void* _res_ptr = untag_ptr(_res);
17477         CHECK_ACCESS(_res_ptr);
17478         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
17479         FREE(untag_ptr(_res));
17480         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
17481 }
17482
17483 static inline uint64_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
17484         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
17485         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
17486         return tag_ptr(ret_conv, true);
17487 }
17488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17489         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)untag_ptr(arg);
17490         int64_t ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
17491         return ret_conv;
17492 }
17493
17494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17495         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)untag_ptr(orig);
17496         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
17497         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
17498         return tag_ptr(ret_conv, true);
17499 }
17500
17501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17502         LDKCVec_MonitorEventZ _res_constr;
17503         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17504         if (_res_constr.datalen > 0)
17505                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
17506         else
17507                 _res_constr.data = NULL;
17508         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17509         for (size_t o = 0; o < _res_constr.datalen; o++) {
17510                 int64_t _res_conv_14 = _res_vals[o];
17511                 void* _res_conv_14_ptr = untag_ptr(_res_conv_14);
17512                 CHECK_ACCESS(_res_conv_14_ptr);
17513                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
17514                 FREE(untag_ptr(_res_conv_14));
17515                 _res_constr.data[o] = _res_conv_14_conv;
17516         }
17517         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17518         CVec_MonitorEventZ_free(_res_constr);
17519 }
17520
17521 static inline uint64_t C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR arg) {
17522         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
17523         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(arg);
17524         return tag_ptr(ret_conv, true);
17525 }
17526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17527         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* arg_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(arg);
17528         int64_t ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(arg_conv);
17529         return ret_conv;
17530 }
17531
17532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17533         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* orig_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(orig);
17534         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
17535         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig_conv);
17536         return tag_ptr(ret_conv, true);
17537 }
17538
17539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_tArray b, int8_tArray c) {
17540         LDKOutPoint a_conv;
17541         a_conv.inner = untag_ptr(a);
17542         a_conv.is_owned = ptr_is_owned(a);
17543         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
17544         a_conv = OutPoint_clone(&a_conv);
17545         LDKCVec_MonitorEventZ b_constr;
17546         b_constr.datalen = (*env)->GetArrayLength(env, b);
17547         if (b_constr.datalen > 0)
17548                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
17549         else
17550                 b_constr.data = NULL;
17551         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
17552         for (size_t o = 0; o < b_constr.datalen; o++) {
17553                 int64_t b_conv_14 = b_vals[o];
17554                 void* b_conv_14_ptr = untag_ptr(b_conv_14);
17555                 CHECK_ACCESS(b_conv_14_ptr);
17556                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
17557                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(b_conv_14));
17558                 b_constr.data[o] = b_conv_14_conv;
17559         }
17560         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
17561         LDKPublicKey c_ref;
17562         CHECK((*env)->GetArrayLength(env, c) == 33);
17563         (*env)->GetByteArrayRegion(env, c, 0, 33, c_ref.compressed_form);
17564         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
17565         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a_conv, b_constr, c_ref);
17566         return tag_ptr(ret_conv, true);
17567 }
17568
17569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17570         if (!ptr_is_owned(_res)) return;
17571         void* _res_ptr = untag_ptr(_res);
17572         CHECK_ACCESS(_res_ptr);
17573         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_ptr);
17574         FREE(untag_ptr(_res));
17575         C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res_conv);
17576 }
17577
17578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17579         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res_constr;
17580         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17581         if (_res_constr.datalen > 0)
17582                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
17583         else
17584                 _res_constr.data = NULL;
17585         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17586         for (size_t x = 0; x < _res_constr.datalen; x++) {
17587                 int64_t _res_conv_49 = _res_vals[x];
17588                 void* _res_conv_49_ptr = untag_ptr(_res_conv_49);
17589                 CHECK_ACCESS(_res_conv_49_ptr);
17590                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_conv_49_ptr);
17591                 FREE(untag_ptr(_res_conv_49));
17592                 _res_constr.data[x] = _res_conv_49_conv;
17593         }
17594         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17595         CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(_res_constr);
17596 }
17597
17598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17599         LDKFixedPenaltyScorer o_conv;
17600         o_conv.inner = untag_ptr(o);
17601         o_conv.is_owned = ptr_is_owned(o);
17602         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17603         o_conv = FixedPenaltyScorer_clone(&o_conv);
17604         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17605         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
17606         return tag_ptr(ret_conv, true);
17607 }
17608
17609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17610         LDKDecodeError e_conv;
17611         e_conv.inner = untag_ptr(e);
17612         e_conv.is_owned = ptr_is_owned(e);
17613         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17614         e_conv = DecodeError_clone(&e_conv);
17615         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17616         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
17617         return tag_ptr(ret_conv, true);
17618 }
17619
17620 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17621         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(o);
17622         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
17623         return ret_conv;
17624 }
17625
17626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17627         if (!ptr_is_owned(_res)) return;
17628         void* _res_ptr = untag_ptr(_res);
17629         CHECK_ACCESS(_res_ptr);
17630         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
17631         FREE(untag_ptr(_res));
17632         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
17633 }
17634
17635 static inline uint64_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
17636         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17637         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
17638         return tag_ptr(ret_conv, true);
17639 }
17640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17641         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(arg);
17642         int64_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
17643         return ret_conv;
17644 }
17645
17646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17647         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(orig);
17648         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
17649         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
17650         return tag_ptr(ret_conv, true);
17651 }
17652
17653 static inline uint64_t C2Tuple_u64u64Z_clone_ptr(LDKC2Tuple_u64u64Z *NONNULL_PTR arg) {
17654         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
17655         *ret_conv = C2Tuple_u64u64Z_clone(arg);
17656         return tag_ptr(ret_conv, true);
17657 }
17658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17659         LDKC2Tuple_u64u64Z* arg_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(arg);
17660         int64_t ret_conv = C2Tuple_u64u64Z_clone_ptr(arg_conv);
17661         return ret_conv;
17662 }
17663
17664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17665         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(orig);
17666         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
17667         *ret_conv = C2Tuple_u64u64Z_clone(orig_conv);
17668         return tag_ptr(ret_conv, true);
17669 }
17670
17671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
17672         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
17673         *ret_conv = C2Tuple_u64u64Z_new(a, b);
17674         return tag_ptr(ret_conv, true);
17675 }
17676
17677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
17678         if (!ptr_is_owned(_res)) return;
17679         void* _res_ptr = untag_ptr(_res);
17680         CHECK_ACCESS(_res_ptr);
17681         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(_res_ptr);
17682         FREE(untag_ptr(_res));
17683         C2Tuple_u64u64Z_free(_res_conv);
17684 }
17685
17686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17687         void* o_ptr = untag_ptr(o);
17688         CHECK_ACCESS(o_ptr);
17689         LDKC2Tuple_u64u64Z o_conv = *(LDKC2Tuple_u64u64Z*)(o_ptr);
17690         o_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)untag_ptr(o));
17691         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17692         *ret_copy = COption_C2Tuple_u64u64ZZ_some(o_conv);
17693         int64_t ret_ref = tag_ptr(ret_copy, true);
17694         return ret_ref;
17695 }
17696
17697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1none(JNIEnv *env, jclass clz) {
17698         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17699         *ret_copy = COption_C2Tuple_u64u64ZZ_none();
17700         int64_t ret_ref = tag_ptr(ret_copy, true);
17701         return ret_ref;
17702 }
17703
17704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17705         if (!ptr_is_owned(_res)) return;
17706         void* _res_ptr = untag_ptr(_res);
17707         CHECK_ACCESS(_res_ptr);
17708         LDKCOption_C2Tuple_u64u64ZZ _res_conv = *(LDKCOption_C2Tuple_u64u64ZZ*)(_res_ptr);
17709         FREE(untag_ptr(_res));
17710         COption_C2Tuple_u64u64ZZ_free(_res_conv);
17711 }
17712
17713 static inline uint64_t COption_C2Tuple_u64u64ZZ_clone_ptr(LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR arg) {
17714         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17715         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(arg);
17716         int64_t ret_ref = tag_ptr(ret_copy, true);
17717         return ret_ref;
17718 }
17719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17720         LDKCOption_C2Tuple_u64u64ZZ* arg_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(arg);
17721         int64_t ret_conv = COption_C2Tuple_u64u64ZZ_clone_ptr(arg_conv);
17722         return ret_conv;
17723 }
17724
17725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17726         LDKCOption_C2Tuple_u64u64ZZ* orig_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(orig);
17727         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
17728         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(orig_conv);
17729         int64_t ret_ref = tag_ptr(ret_copy, true);
17730         return ret_ref;
17731 }
17732
17733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeIdZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17734         LDKCVec_NodeIdZ _res_constr;
17735         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17736         if (_res_constr.datalen > 0)
17737                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
17738         else
17739                 _res_constr.data = NULL;
17740         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17741         for (size_t i = 0; i < _res_constr.datalen; i++) {
17742                 int64_t _res_conv_8 = _res_vals[i];
17743                 LDKNodeId _res_conv_8_conv;
17744                 _res_conv_8_conv.inner = untag_ptr(_res_conv_8);
17745                 _res_conv_8_conv.is_owned = ptr_is_owned(_res_conv_8);
17746                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
17747                 _res_constr.data[i] = _res_conv_8_conv;
17748         }
17749         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17750         CVec_NodeIdZ_free(_res_constr);
17751 }
17752
17753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17754         LDKProbabilisticScorer o_conv;
17755         o_conv.inner = untag_ptr(o);
17756         o_conv.is_owned = ptr_is_owned(o);
17757         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17758         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
17759         
17760         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
17761         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
17762         return tag_ptr(ret_conv, true);
17763 }
17764
17765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17766         LDKDecodeError e_conv;
17767         e_conv.inner = untag_ptr(e);
17768         e_conv.is_owned = ptr_is_owned(e);
17769         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17770         e_conv = DecodeError_clone(&e_conv);
17771         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
17772         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
17773         return tag_ptr(ret_conv, true);
17774 }
17775
17776 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17777         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(o);
17778         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
17779         return ret_conv;
17780 }
17781
17782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17783         if (!ptr_is_owned(_res)) return;
17784         void* _res_ptr = untag_ptr(_res);
17785         CHECK_ACCESS(_res_ptr);
17786         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
17787         FREE(untag_ptr(_res));
17788         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
17789 }
17790
17791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17792         LDKInitFeatures o_conv;
17793         o_conv.inner = untag_ptr(o);
17794         o_conv.is_owned = ptr_is_owned(o);
17795         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17796         o_conv = InitFeatures_clone(&o_conv);
17797         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17798         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
17799         return tag_ptr(ret_conv, true);
17800 }
17801
17802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17803         LDKDecodeError e_conv;
17804         e_conv.inner = untag_ptr(e);
17805         e_conv.is_owned = ptr_is_owned(e);
17806         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17807         e_conv = DecodeError_clone(&e_conv);
17808         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17809         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
17810         return tag_ptr(ret_conv, true);
17811 }
17812
17813 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17814         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(o);
17815         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
17816         return ret_conv;
17817 }
17818
17819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17820         if (!ptr_is_owned(_res)) return;
17821         void* _res_ptr = untag_ptr(_res);
17822         CHECK_ACCESS(_res_ptr);
17823         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
17824         FREE(untag_ptr(_res));
17825         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
17826 }
17827
17828 static inline uint64_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17829         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17830         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
17831         return tag_ptr(ret_conv, true);
17832 }
17833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17834         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(arg);
17835         int64_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17836         return ret_conv;
17837 }
17838
17839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17840         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(orig);
17841         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
17842         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
17843         return tag_ptr(ret_conv, true);
17844 }
17845
17846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17847         LDKChannelFeatures o_conv;
17848         o_conv.inner = untag_ptr(o);
17849         o_conv.is_owned = ptr_is_owned(o);
17850         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17851         o_conv = ChannelFeatures_clone(&o_conv);
17852         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17853         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
17854         return tag_ptr(ret_conv, true);
17855 }
17856
17857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17858         LDKDecodeError e_conv;
17859         e_conv.inner = untag_ptr(e);
17860         e_conv.is_owned = ptr_is_owned(e);
17861         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17862         e_conv = DecodeError_clone(&e_conv);
17863         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17864         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
17865         return tag_ptr(ret_conv, true);
17866 }
17867
17868 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17869         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(o);
17870         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
17871         return ret_conv;
17872 }
17873
17874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17875         if (!ptr_is_owned(_res)) return;
17876         void* _res_ptr = untag_ptr(_res);
17877         CHECK_ACCESS(_res_ptr);
17878         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
17879         FREE(untag_ptr(_res));
17880         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
17881 }
17882
17883 static inline uint64_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17884         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17885         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
17886         return tag_ptr(ret_conv, true);
17887 }
17888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17889         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(arg);
17890         int64_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17891         return ret_conv;
17892 }
17893
17894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17895         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(orig);
17896         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
17897         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
17898         return tag_ptr(ret_conv, true);
17899 }
17900
17901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17902         LDKNodeFeatures o_conv;
17903         o_conv.inner = untag_ptr(o);
17904         o_conv.is_owned = ptr_is_owned(o);
17905         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17906         o_conv = NodeFeatures_clone(&o_conv);
17907         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17908         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
17909         return tag_ptr(ret_conv, true);
17910 }
17911
17912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17913         LDKDecodeError e_conv;
17914         e_conv.inner = untag_ptr(e);
17915         e_conv.is_owned = ptr_is_owned(e);
17916         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17917         e_conv = DecodeError_clone(&e_conv);
17918         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17919         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
17920         return tag_ptr(ret_conv, true);
17921 }
17922
17923 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17924         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(o);
17925         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
17926         return ret_conv;
17927 }
17928
17929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17930         if (!ptr_is_owned(_res)) return;
17931         void* _res_ptr = untag_ptr(_res);
17932         CHECK_ACCESS(_res_ptr);
17933         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
17934         FREE(untag_ptr(_res));
17935         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
17936 }
17937
17938 static inline uint64_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17939         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17940         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
17941         return tag_ptr(ret_conv, true);
17942 }
17943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17944         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(arg);
17945         int64_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
17946         return ret_conv;
17947 }
17948
17949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17950         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(orig);
17951         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
17952         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
17953         return tag_ptr(ret_conv, true);
17954 }
17955
17956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17957         LDKInvoiceFeatures o_conv;
17958         o_conv.inner = untag_ptr(o);
17959         o_conv.is_owned = ptr_is_owned(o);
17960         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17961         o_conv = InvoiceFeatures_clone(&o_conv);
17962         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17963         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
17964         return tag_ptr(ret_conv, true);
17965 }
17966
17967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17968         LDKDecodeError e_conv;
17969         e_conv.inner = untag_ptr(e);
17970         e_conv.is_owned = ptr_is_owned(e);
17971         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17972         e_conv = DecodeError_clone(&e_conv);
17973         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17974         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
17975         return tag_ptr(ret_conv, true);
17976 }
17977
17978 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17979         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(o);
17980         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
17981         return ret_conv;
17982 }
17983
17984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17985         if (!ptr_is_owned(_res)) return;
17986         void* _res_ptr = untag_ptr(_res);
17987         CHECK_ACCESS(_res_ptr);
17988         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
17989         FREE(untag_ptr(_res));
17990         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
17991 }
17992
17993 static inline uint64_t CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
17994         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
17995         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(arg);
17996         return tag_ptr(ret_conv, true);
17997 }
17998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17999         LDKCResult_InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(arg);
18000         int64_t ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18001         return ret_conv;
18002 }
18003
18004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18005         LDKCResult_InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(orig);
18006         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18007         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
18008         return tag_ptr(ret_conv, true);
18009 }
18010
18011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18012         LDKChannelTypeFeatures o_conv;
18013         o_conv.inner = untag_ptr(o);
18014         o_conv.is_owned = ptr_is_owned(o);
18015         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18016         o_conv = ChannelTypeFeatures_clone(&o_conv);
18017         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18018         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
18019         return tag_ptr(ret_conv, true);
18020 }
18021
18022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18023         LDKDecodeError e_conv;
18024         e_conv.inner = untag_ptr(e);
18025         e_conv.is_owned = ptr_is_owned(e);
18026         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18027         e_conv = DecodeError_clone(&e_conv);
18028         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18029         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
18030         return tag_ptr(ret_conv, true);
18031 }
18032
18033 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18034         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(o);
18035         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
18036         return ret_conv;
18037 }
18038
18039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18040         if (!ptr_is_owned(_res)) return;
18041         void* _res_ptr = untag_ptr(_res);
18042         CHECK_ACCESS(_res_ptr);
18043         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
18044         FREE(untag_ptr(_res));
18045         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
18046 }
18047
18048 static inline uint64_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18049         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18050         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
18051         return tag_ptr(ret_conv, true);
18052 }
18053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18054         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(arg);
18055         int64_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18056         return ret_conv;
18057 }
18058
18059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18060         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(orig);
18061         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18062         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
18063         return tag_ptr(ret_conv, true);
18064 }
18065
18066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18067         LDKNodeId o_conv;
18068         o_conv.inner = untag_ptr(o);
18069         o_conv.is_owned = ptr_is_owned(o);
18070         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18071         o_conv = NodeId_clone(&o_conv);
18072         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18073         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
18074         return tag_ptr(ret_conv, true);
18075 }
18076
18077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18078         LDKDecodeError e_conv;
18079         e_conv.inner = untag_ptr(e);
18080         e_conv.is_owned = ptr_is_owned(e);
18081         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18082         e_conv = DecodeError_clone(&e_conv);
18083         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18084         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
18085         return tag_ptr(ret_conv, true);
18086 }
18087
18088 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18089         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(o);
18090         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
18091         return ret_conv;
18092 }
18093
18094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18095         if (!ptr_is_owned(_res)) return;
18096         void* _res_ptr = untag_ptr(_res);
18097         CHECK_ACCESS(_res_ptr);
18098         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
18099         FREE(untag_ptr(_res));
18100         CResult_NodeIdDecodeErrorZ_free(_res_conv);
18101 }
18102
18103 static inline uint64_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
18104         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18105         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
18106         return tag_ptr(ret_conv, true);
18107 }
18108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18109         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(arg);
18110         int64_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
18111         return ret_conv;
18112 }
18113
18114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18115         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(orig);
18116         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18117         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
18118         return tag_ptr(ret_conv, true);
18119 }
18120
18121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18122         void* o_ptr = untag_ptr(o);
18123         CHECK_ACCESS(o_ptr);
18124         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
18125         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(o));
18126         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
18127         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
18128         return tag_ptr(ret_conv, true);
18129 }
18130
18131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18132         LDKDecodeError e_conv;
18133         e_conv.inner = untag_ptr(e);
18134         e_conv.is_owned = ptr_is_owned(e);
18135         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18136         e_conv = DecodeError_clone(&e_conv);
18137         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
18138         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
18139         return tag_ptr(ret_conv, true);
18140 }
18141
18142 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18143         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(o);
18144         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
18145         return ret_conv;
18146 }
18147
18148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18149         if (!ptr_is_owned(_res)) return;
18150         void* _res_ptr = untag_ptr(_res);
18151         CHECK_ACCESS(_res_ptr);
18152         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
18153         FREE(untag_ptr(_res));
18154         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
18155 }
18156
18157 static inline uint64_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
18158         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
18159         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
18160         return tag_ptr(ret_conv, true);
18161 }
18162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18163         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(arg);
18164         int64_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
18165         return ret_conv;
18166 }
18167
18168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18169         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(orig);
18170         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
18171         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
18172         return tag_ptr(ret_conv, true);
18173 }
18174
18175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
18176         void* o_ptr = untag_ptr(o);
18177         CHECK_ACCESS(o_ptr);
18178         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
18179         if (o_conv.free == LDKAccess_JCalls_free) {
18180                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
18181                 LDKAccess_JCalls_cloned(&o_conv);
18182         }
18183         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
18184         *ret_copy = COption_AccessZ_some(o_conv);
18185         int64_t ret_ref = tag_ptr(ret_copy, true);
18186         return ret_ref;
18187 }
18188
18189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
18190         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
18191         *ret_copy = COption_AccessZ_none();
18192         int64_t ret_ref = tag_ptr(ret_copy, true);
18193         return ret_ref;
18194 }
18195
18196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18197         if (!ptr_is_owned(_res)) return;
18198         void* _res_ptr = untag_ptr(_res);
18199         CHECK_ACCESS(_res_ptr);
18200         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
18201         FREE(untag_ptr(_res));
18202         COption_AccessZ_free(_res_conv);
18203 }
18204
18205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
18206         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
18207         *ret_conv = CResult_boolLightningErrorZ_ok(o);
18208         return tag_ptr(ret_conv, true);
18209 }
18210
18211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18212         LDKLightningError e_conv;
18213         e_conv.inner = untag_ptr(e);
18214         e_conv.is_owned = ptr_is_owned(e);
18215         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18216         e_conv = LightningError_clone(&e_conv);
18217         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
18218         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
18219         return tag_ptr(ret_conv, true);
18220 }
18221
18222 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18223         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(o);
18224         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
18225         return ret_conv;
18226 }
18227
18228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18229         if (!ptr_is_owned(_res)) return;
18230         void* _res_ptr = untag_ptr(_res);
18231         CHECK_ACCESS(_res_ptr);
18232         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
18233         FREE(untag_ptr(_res));
18234         CResult_boolLightningErrorZ_free(_res_conv);
18235 }
18236
18237 static inline uint64_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
18238         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
18239         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
18240         return tag_ptr(ret_conv, true);
18241 }
18242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18243         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(arg);
18244         int64_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
18245         return ret_conv;
18246 }
18247
18248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18249         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(orig);
18250         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
18251         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
18252         return tag_ptr(ret_conv, true);
18253 }
18254
18255 static inline uint64_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
18256         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
18257         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
18258         return tag_ptr(ret_conv, true);
18259 }
18260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18261         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(arg);
18262         int64_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
18263         return ret_conv;
18264 }
18265
18266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18267         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(orig);
18268         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
18269         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
18270         return tag_ptr(ret_conv, true);
18271 }
18272
18273 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) {
18274         LDKChannelAnnouncement a_conv;
18275         a_conv.inner = untag_ptr(a);
18276         a_conv.is_owned = ptr_is_owned(a);
18277         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18278         a_conv = ChannelAnnouncement_clone(&a_conv);
18279         LDKChannelUpdate b_conv;
18280         b_conv.inner = untag_ptr(b);
18281         b_conv.is_owned = ptr_is_owned(b);
18282         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
18283         b_conv = ChannelUpdate_clone(&b_conv);
18284         LDKChannelUpdate c_conv;
18285         c_conv.inner = untag_ptr(c);
18286         c_conv.is_owned = ptr_is_owned(c);
18287         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
18288         c_conv = ChannelUpdate_clone(&c_conv);
18289         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
18290         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
18291         return tag_ptr(ret_conv, true);
18292 }
18293
18294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18295         if (!ptr_is_owned(_res)) return;
18296         void* _res_ptr = untag_ptr(_res);
18297         CHECK_ACCESS(_res_ptr);
18298         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
18299         FREE(untag_ptr(_res));
18300         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
18301 }
18302
18303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
18304         void* o_ptr = untag_ptr(o);
18305         CHECK_ACCESS(o_ptr);
18306         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ o_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(o_ptr);
18307         o_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(o));
18308         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
18309         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some(o_conv);
18310         int64_t ret_ref = tag_ptr(ret_copy, true);
18311         return ret_ref;
18312 }
18313
18314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1none(JNIEnv *env, jclass clz) {
18315         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
18316         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_none();
18317         int64_t ret_ref = tag_ptr(ret_copy, true);
18318         return ret_ref;
18319 }
18320
18321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18322         if (!ptr_is_owned(_res)) return;
18323         void* _res_ptr = untag_ptr(_res);
18324         CHECK_ACCESS(_res_ptr);
18325         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_conv = *(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(_res_ptr);
18326         FREE(untag_ptr(_res));
18327         COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_conv);
18328 }
18329
18330 static inline uint64_t COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *NONNULL_PTR arg) {
18331         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
18332         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(arg);
18333         int64_t ret_ref = tag_ptr(ret_copy, true);
18334         return ret_ref;
18335 }
18336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18337         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* arg_conv = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(arg);
18338         int64_t ret_conv = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(arg_conv);
18339         return ret_conv;
18340 }
18341
18342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18343         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* orig_conv = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(orig);
18344         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
18345         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(orig_conv);
18346         int64_t ret_ref = tag_ptr(ret_copy, true);
18347         return ret_ref;
18348 }
18349
18350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
18351         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18352         *ret_conv = CResult_NoneLightningErrorZ_ok();
18353         return tag_ptr(ret_conv, true);
18354 }
18355
18356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18357         LDKLightningError e_conv;
18358         e_conv.inner = untag_ptr(e);
18359         e_conv.is_owned = ptr_is_owned(e);
18360         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18361         e_conv = LightningError_clone(&e_conv);
18362         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18363         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
18364         return tag_ptr(ret_conv, true);
18365 }
18366
18367 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18368         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(o);
18369         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
18370         return ret_conv;
18371 }
18372
18373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18374         if (!ptr_is_owned(_res)) return;
18375         void* _res_ptr = untag_ptr(_res);
18376         CHECK_ACCESS(_res_ptr);
18377         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
18378         FREE(untag_ptr(_res));
18379         CResult_NoneLightningErrorZ_free(_res_conv);
18380 }
18381
18382 static inline uint64_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
18383         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18384         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
18385         return tag_ptr(ret_conv, true);
18386 }
18387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18388         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(arg);
18389         int64_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
18390         return ret_conv;
18391 }
18392
18393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18394         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(orig);
18395         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
18396         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
18397         return tag_ptr(ret_conv, true);
18398 }
18399
18400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18401         LDKChannelUpdateInfo o_conv;
18402         o_conv.inner = untag_ptr(o);
18403         o_conv.is_owned = ptr_is_owned(o);
18404         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18405         o_conv = ChannelUpdateInfo_clone(&o_conv);
18406         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18407         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
18408         return tag_ptr(ret_conv, true);
18409 }
18410
18411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18412         LDKDecodeError e_conv;
18413         e_conv.inner = untag_ptr(e);
18414         e_conv.is_owned = ptr_is_owned(e);
18415         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18416         e_conv = DecodeError_clone(&e_conv);
18417         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18418         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
18419         return tag_ptr(ret_conv, true);
18420 }
18421
18422 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18423         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(o);
18424         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
18425         return ret_conv;
18426 }
18427
18428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18429         if (!ptr_is_owned(_res)) return;
18430         void* _res_ptr = untag_ptr(_res);
18431         CHECK_ACCESS(_res_ptr);
18432         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
18433         FREE(untag_ptr(_res));
18434         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
18435 }
18436
18437 static inline uint64_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
18438         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18439         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
18440         return tag_ptr(ret_conv, true);
18441 }
18442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18443         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(arg);
18444         int64_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
18445         return ret_conv;
18446 }
18447
18448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18449         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(orig);
18450         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
18451         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
18452         return tag_ptr(ret_conv, true);
18453 }
18454
18455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18456         LDKChannelInfo o_conv;
18457         o_conv.inner = untag_ptr(o);
18458         o_conv.is_owned = ptr_is_owned(o);
18459         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18460         o_conv = ChannelInfo_clone(&o_conv);
18461         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18462         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
18463         return tag_ptr(ret_conv, true);
18464 }
18465
18466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18467         LDKDecodeError e_conv;
18468         e_conv.inner = untag_ptr(e);
18469         e_conv.is_owned = ptr_is_owned(e);
18470         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18471         e_conv = DecodeError_clone(&e_conv);
18472         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18473         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
18474         return tag_ptr(ret_conv, true);
18475 }
18476
18477 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18478         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(o);
18479         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
18480         return ret_conv;
18481 }
18482
18483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18484         if (!ptr_is_owned(_res)) return;
18485         void* _res_ptr = untag_ptr(_res);
18486         CHECK_ACCESS(_res_ptr);
18487         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
18488         FREE(untag_ptr(_res));
18489         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
18490 }
18491
18492 static inline uint64_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
18493         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18494         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
18495         return tag_ptr(ret_conv, true);
18496 }
18497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18498         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(arg);
18499         int64_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
18500         return ret_conv;
18501 }
18502
18503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18504         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(orig);
18505         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
18506         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
18507         return tag_ptr(ret_conv, true);
18508 }
18509
18510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18511         LDKRoutingFees o_conv;
18512         o_conv.inner = untag_ptr(o);
18513         o_conv.is_owned = ptr_is_owned(o);
18514         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18515         o_conv = RoutingFees_clone(&o_conv);
18516         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18517         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
18518         return tag_ptr(ret_conv, true);
18519 }
18520
18521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18522         LDKDecodeError e_conv;
18523         e_conv.inner = untag_ptr(e);
18524         e_conv.is_owned = ptr_is_owned(e);
18525         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18526         e_conv = DecodeError_clone(&e_conv);
18527         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18528         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
18529         return tag_ptr(ret_conv, true);
18530 }
18531
18532 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18533         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(o);
18534         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
18535         return ret_conv;
18536 }
18537
18538 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18539         if (!ptr_is_owned(_res)) return;
18540         void* _res_ptr = untag_ptr(_res);
18541         CHECK_ACCESS(_res_ptr);
18542         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
18543         FREE(untag_ptr(_res));
18544         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
18545 }
18546
18547 static inline uint64_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
18548         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18549         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
18550         return tag_ptr(ret_conv, true);
18551 }
18552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18553         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(arg);
18554         int64_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
18555         return ret_conv;
18556 }
18557
18558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18559         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(orig);
18560         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
18561         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
18562         return tag_ptr(ret_conv, true);
18563 }
18564
18565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18566         LDKCVec_NetAddressZ _res_constr;
18567         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18568         if (_res_constr.datalen > 0)
18569                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18570         else
18571                 _res_constr.data = NULL;
18572         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18573         for (size_t m = 0; m < _res_constr.datalen; m++) {
18574                 int64_t _res_conv_12 = _res_vals[m];
18575                 void* _res_conv_12_ptr = untag_ptr(_res_conv_12);
18576                 CHECK_ACCESS(_res_conv_12_ptr);
18577                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
18578                 FREE(untag_ptr(_res_conv_12));
18579                 _res_constr.data[m] = _res_conv_12_conv;
18580         }
18581         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18582         CVec_NetAddressZ_free(_res_constr);
18583 }
18584
18585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18586         LDKNodeAnnouncementInfo o_conv;
18587         o_conv.inner = untag_ptr(o);
18588         o_conv.is_owned = ptr_is_owned(o);
18589         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18590         o_conv = NodeAnnouncementInfo_clone(&o_conv);
18591         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18592         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
18593         return tag_ptr(ret_conv, true);
18594 }
18595
18596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18597         LDKDecodeError e_conv;
18598         e_conv.inner = untag_ptr(e);
18599         e_conv.is_owned = ptr_is_owned(e);
18600         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18601         e_conv = DecodeError_clone(&e_conv);
18602         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18603         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
18604         return tag_ptr(ret_conv, true);
18605 }
18606
18607 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18608         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(o);
18609         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
18610         return ret_conv;
18611 }
18612
18613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18614         if (!ptr_is_owned(_res)) return;
18615         void* _res_ptr = untag_ptr(_res);
18616         CHECK_ACCESS(_res_ptr);
18617         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
18618         FREE(untag_ptr(_res));
18619         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
18620 }
18621
18622 static inline uint64_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
18623         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18624         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
18625         return tag_ptr(ret_conv, true);
18626 }
18627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18628         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(arg);
18629         int64_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
18630         return ret_conv;
18631 }
18632
18633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18634         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(orig);
18635         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
18636         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
18637         return tag_ptr(ret_conv, true);
18638 }
18639
18640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18641         LDKNodeAlias o_conv;
18642         o_conv.inner = untag_ptr(o);
18643         o_conv.is_owned = ptr_is_owned(o);
18644         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18645         o_conv = NodeAlias_clone(&o_conv);
18646         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18647         *ret_conv = CResult_NodeAliasDecodeErrorZ_ok(o_conv);
18648         return tag_ptr(ret_conv, true);
18649 }
18650
18651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18652         LDKDecodeError e_conv;
18653         e_conv.inner = untag_ptr(e);
18654         e_conv.is_owned = ptr_is_owned(e);
18655         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18656         e_conv = DecodeError_clone(&e_conv);
18657         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18658         *ret_conv = CResult_NodeAliasDecodeErrorZ_err(e_conv);
18659         return tag_ptr(ret_conv, true);
18660 }
18661
18662 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18663         LDKCResult_NodeAliasDecodeErrorZ* o_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(o);
18664         jboolean ret_conv = CResult_NodeAliasDecodeErrorZ_is_ok(o_conv);
18665         return ret_conv;
18666 }
18667
18668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18669         if (!ptr_is_owned(_res)) return;
18670         void* _res_ptr = untag_ptr(_res);
18671         CHECK_ACCESS(_res_ptr);
18672         LDKCResult_NodeAliasDecodeErrorZ _res_conv = *(LDKCResult_NodeAliasDecodeErrorZ*)(_res_ptr);
18673         FREE(untag_ptr(_res));
18674         CResult_NodeAliasDecodeErrorZ_free(_res_conv);
18675 }
18676
18677 static inline uint64_t CResult_NodeAliasDecodeErrorZ_clone_ptr(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR arg) {
18678         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18679         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(arg);
18680         return tag_ptr(ret_conv, true);
18681 }
18682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18683         LDKCResult_NodeAliasDecodeErrorZ* arg_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(arg);
18684         int64_t ret_conv = CResult_NodeAliasDecodeErrorZ_clone_ptr(arg_conv);
18685         return ret_conv;
18686 }
18687
18688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18689         LDKCResult_NodeAliasDecodeErrorZ* orig_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(orig);
18690         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
18691         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(orig_conv);
18692         return tag_ptr(ret_conv, true);
18693 }
18694
18695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18696         LDKNodeInfo o_conv;
18697         o_conv.inner = untag_ptr(o);
18698         o_conv.is_owned = ptr_is_owned(o);
18699         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18700         o_conv = NodeInfo_clone(&o_conv);
18701         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18702         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
18703         return tag_ptr(ret_conv, true);
18704 }
18705
18706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18707         LDKDecodeError e_conv;
18708         e_conv.inner = untag_ptr(e);
18709         e_conv.is_owned = ptr_is_owned(e);
18710         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18711         e_conv = DecodeError_clone(&e_conv);
18712         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18713         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
18714         return tag_ptr(ret_conv, true);
18715 }
18716
18717 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18718         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(o);
18719         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
18720         return ret_conv;
18721 }
18722
18723 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18724         if (!ptr_is_owned(_res)) return;
18725         void* _res_ptr = untag_ptr(_res);
18726         CHECK_ACCESS(_res_ptr);
18727         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
18728         FREE(untag_ptr(_res));
18729         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
18730 }
18731
18732 static inline uint64_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
18733         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18734         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
18735         return tag_ptr(ret_conv, true);
18736 }
18737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18738         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(arg);
18739         int64_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
18740         return ret_conv;
18741 }
18742
18743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18744         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(orig);
18745         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
18746         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
18747         return tag_ptr(ret_conv, true);
18748 }
18749
18750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18751         LDKNetworkGraph o_conv;
18752         o_conv.inner = untag_ptr(o);
18753         o_conv.is_owned = ptr_is_owned(o);
18754         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18755         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
18756         
18757         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
18758         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
18759         return tag_ptr(ret_conv, true);
18760 }
18761
18762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18763         LDKDecodeError e_conv;
18764         e_conv.inner = untag_ptr(e);
18765         e_conv.is_owned = ptr_is_owned(e);
18766         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18767         e_conv = DecodeError_clone(&e_conv);
18768         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
18769         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
18770         return tag_ptr(ret_conv, true);
18771 }
18772
18773 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18774         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(o);
18775         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
18776         return ret_conv;
18777 }
18778
18779 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18780         if (!ptr_is_owned(_res)) return;
18781         void* _res_ptr = untag_ptr(_res);
18782         CHECK_ACCESS(_res_ptr);
18783         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
18784         FREE(untag_ptr(_res));
18785         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
18786 }
18787
18788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
18789         LDKCVec_NetAddressZ o_constr;
18790         o_constr.datalen = (*env)->GetArrayLength(env, o);
18791         if (o_constr.datalen > 0)
18792                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
18793         else
18794                 o_constr.data = NULL;
18795         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
18796         for (size_t m = 0; m < o_constr.datalen; m++) {
18797                 int64_t o_conv_12 = o_vals[m];
18798                 void* o_conv_12_ptr = untag_ptr(o_conv_12);
18799                 CHECK_ACCESS(o_conv_12_ptr);
18800                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
18801                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o_conv_12));
18802                 o_constr.data[m] = o_conv_12_conv;
18803         }
18804         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
18805         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18806         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
18807         int64_t ret_ref = tag_ptr(ret_copy, true);
18808         return ret_ref;
18809 }
18810
18811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
18812         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18813         *ret_copy = COption_CVec_NetAddressZZ_none();
18814         int64_t ret_ref = tag_ptr(ret_copy, true);
18815         return ret_ref;
18816 }
18817
18818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18819         if (!ptr_is_owned(_res)) return;
18820         void* _res_ptr = untag_ptr(_res);
18821         CHECK_ACCESS(_res_ptr);
18822         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
18823         FREE(untag_ptr(_res));
18824         COption_CVec_NetAddressZZ_free(_res_conv);
18825 }
18826
18827 static inline uint64_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
18828         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18829         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
18830         int64_t ret_ref = tag_ptr(ret_copy, true);
18831         return ret_ref;
18832 }
18833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18834         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(arg);
18835         int64_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
18836         return ret_conv;
18837 }
18838
18839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18840         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(orig);
18841         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
18842         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
18843         int64_t ret_ref = tag_ptr(ret_copy, true);
18844         return ret_ref;
18845 }
18846
18847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18848         LDKDelayedPaymentOutputDescriptor o_conv;
18849         o_conv.inner = untag_ptr(o);
18850         o_conv.is_owned = ptr_is_owned(o);
18851         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18852         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
18853         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18854         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
18855         return tag_ptr(ret_conv, true);
18856 }
18857
18858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18859         LDKDecodeError e_conv;
18860         e_conv.inner = untag_ptr(e);
18861         e_conv.is_owned = ptr_is_owned(e);
18862         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18863         e_conv = DecodeError_clone(&e_conv);
18864         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18865         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
18866         return tag_ptr(ret_conv, true);
18867 }
18868
18869 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18870         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
18871         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
18872         return ret_conv;
18873 }
18874
18875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18876         if (!ptr_is_owned(_res)) return;
18877         void* _res_ptr = untag_ptr(_res);
18878         CHECK_ACCESS(_res_ptr);
18879         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
18880         FREE(untag_ptr(_res));
18881         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
18882 }
18883
18884 static inline uint64_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
18885         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18886         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
18887         return tag_ptr(ret_conv, true);
18888 }
18889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18890         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
18891         int64_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
18892         return ret_conv;
18893 }
18894
18895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18896         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
18897         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
18898         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
18899         return tag_ptr(ret_conv, true);
18900 }
18901
18902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18903         LDKStaticPaymentOutputDescriptor o_conv;
18904         o_conv.inner = untag_ptr(o);
18905         o_conv.is_owned = ptr_is_owned(o);
18906         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18907         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
18908         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18909         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
18910         return tag_ptr(ret_conv, true);
18911 }
18912
18913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18914         LDKDecodeError e_conv;
18915         e_conv.inner = untag_ptr(e);
18916         e_conv.is_owned = ptr_is_owned(e);
18917         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18918         e_conv = DecodeError_clone(&e_conv);
18919         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18920         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
18921         return tag_ptr(ret_conv, true);
18922 }
18923
18924 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18925         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
18926         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
18927         return ret_conv;
18928 }
18929
18930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18931         if (!ptr_is_owned(_res)) return;
18932         void* _res_ptr = untag_ptr(_res);
18933         CHECK_ACCESS(_res_ptr);
18934         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
18935         FREE(untag_ptr(_res));
18936         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
18937 }
18938
18939 static inline uint64_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
18940         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18941         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
18942         return tag_ptr(ret_conv, true);
18943 }
18944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18945         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
18946         int64_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
18947         return ret_conv;
18948 }
18949
18950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18951         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
18952         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
18953         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
18954         return tag_ptr(ret_conv, true);
18955 }
18956
18957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18958         void* o_ptr = untag_ptr(o);
18959         CHECK_ACCESS(o_ptr);
18960         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
18961         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(o));
18962         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18963         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
18964         return tag_ptr(ret_conv, true);
18965 }
18966
18967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18968         LDKDecodeError e_conv;
18969         e_conv.inner = untag_ptr(e);
18970         e_conv.is_owned = ptr_is_owned(e);
18971         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18972         e_conv = DecodeError_clone(&e_conv);
18973         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18974         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
18975         return tag_ptr(ret_conv, true);
18976 }
18977
18978 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18979         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(o);
18980         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
18981         return ret_conv;
18982 }
18983
18984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18985         if (!ptr_is_owned(_res)) return;
18986         void* _res_ptr = untag_ptr(_res);
18987         CHECK_ACCESS(_res_ptr);
18988         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
18989         FREE(untag_ptr(_res));
18990         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
18991 }
18992
18993 static inline uint64_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
18994         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
18995         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
18996         return tag_ptr(ret_conv, true);
18997 }
18998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18999         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
19000         int64_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
19001         return ret_conv;
19002 }
19003
19004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19005         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
19006         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
19007         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
19008         return tag_ptr(ret_conv, true);
19009 }
19010
19011 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PaymentPreimageZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19012         LDKCVec_PaymentPreimageZ _res_constr;
19013         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19014         if (_res_constr.datalen > 0)
19015                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
19016         else
19017                 _res_constr.data = NULL;
19018         for (size_t i = 0; i < _res_constr.datalen; i++) {
19019                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19020                 LDKThirtyTwoBytes _res_conv_8_ref;
19021                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
19022                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
19023                 _res_constr.data[i] = _res_conv_8_ref;
19024         }
19025         CVec_PaymentPreimageZ_free(_res_constr);
19026 }
19027
19028 static inline uint64_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
19029         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
19030         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
19031         return tag_ptr(ret_conv, true);
19032 }
19033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19034         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(arg);
19035         int64_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
19036         return ret_conv;
19037 }
19038
19039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19040         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(orig);
19041         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
19042         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
19043         return tag_ptr(ret_conv, true);
19044 }
19045
19046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
19047         LDKSignature a_ref;
19048         CHECK((*env)->GetArrayLength(env, a) == 64);
19049         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
19050         LDKCVec_SignatureZ b_constr;
19051         b_constr.datalen = (*env)->GetArrayLength(env, b);
19052         if (b_constr.datalen > 0)
19053                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19054         else
19055                 b_constr.data = NULL;
19056         for (size_t i = 0; i < b_constr.datalen; i++) {
19057                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
19058                 LDKSignature b_conv_8_ref;
19059                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
19060                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
19061                 b_constr.data[i] = b_conv_8_ref;
19062         }
19063         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
19064         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
19065         return tag_ptr(ret_conv, true);
19066 }
19067
19068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19069         if (!ptr_is_owned(_res)) return;
19070         void* _res_ptr = untag_ptr(_res);
19071         CHECK_ACCESS(_res_ptr);
19072         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
19073         FREE(untag_ptr(_res));
19074         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
19075 }
19076
19077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19078         void* o_ptr = untag_ptr(o);
19079         CHECK_ACCESS(o_ptr);
19080         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
19081         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(o));
19082         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
19083         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
19084         return tag_ptr(ret_conv, true);
19085 }
19086
19087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
19088         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
19089         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
19090         return tag_ptr(ret_conv, true);
19091 }
19092
19093 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19094         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(o);
19095         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
19096         return ret_conv;
19097 }
19098
19099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19100         if (!ptr_is_owned(_res)) return;
19101         void* _res_ptr = untag_ptr(_res);
19102         CHECK_ACCESS(_res_ptr);
19103         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
19104         FREE(untag_ptr(_res));
19105         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
19106 }
19107
19108 static inline uint64_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
19109         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
19110         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
19111         return tag_ptr(ret_conv, true);
19112 }
19113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19114         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(arg);
19115         int64_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
19116         return ret_conv;
19117 }
19118
19119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19120         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(orig);
19121         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
19122         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
19123         return tag_ptr(ret_conv, true);
19124 }
19125
19126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19127         LDKSignature o_ref;
19128         CHECK((*env)->GetArrayLength(env, o) == 64);
19129         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
19130         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
19131         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
19132         return tag_ptr(ret_conv, true);
19133 }
19134
19135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
19136         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
19137         *ret_conv = CResult_SignatureNoneZ_err();
19138         return tag_ptr(ret_conv, true);
19139 }
19140
19141 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19142         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(o);
19143         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
19144         return ret_conv;
19145 }
19146
19147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19148         if (!ptr_is_owned(_res)) return;
19149         void* _res_ptr = untag_ptr(_res);
19150         CHECK_ACCESS(_res_ptr);
19151         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
19152         FREE(untag_ptr(_res));
19153         CResult_SignatureNoneZ_free(_res_conv);
19154 }
19155
19156 static inline uint64_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
19157         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
19158         *ret_conv = CResult_SignatureNoneZ_clone(arg);
19159         return tag_ptr(ret_conv, true);
19160 }
19161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19162         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(arg);
19163         int64_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
19164         return ret_conv;
19165 }
19166
19167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19168         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(orig);
19169         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
19170         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
19171         return tag_ptr(ret_conv, true);
19172 }
19173
19174 static inline uint64_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
19175         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
19176         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
19177         return tag_ptr(ret_conv, true);
19178 }
19179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19180         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(arg);
19181         int64_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
19182         return ret_conv;
19183 }
19184
19185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19186         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(orig);
19187         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
19188         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
19189         return tag_ptr(ret_conv, true);
19190 }
19191
19192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
19193         LDKSignature a_ref;
19194         CHECK((*env)->GetArrayLength(env, a) == 64);
19195         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
19196         LDKSignature b_ref;
19197         CHECK((*env)->GetArrayLength(env, b) == 64);
19198         (*env)->GetByteArrayRegion(env, b, 0, 64, b_ref.compact_form);
19199         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
19200         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
19201         return tag_ptr(ret_conv, true);
19202 }
19203
19204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19205         if (!ptr_is_owned(_res)) return;
19206         void* _res_ptr = untag_ptr(_res);
19207         CHECK_ACCESS(_res_ptr);
19208         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
19209         FREE(untag_ptr(_res));
19210         C2Tuple_SignatureSignatureZ_free(_res_conv);
19211 }
19212
19213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19214         void* o_ptr = untag_ptr(o);
19215         CHECK_ACCESS(o_ptr);
19216         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
19217         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)untag_ptr(o));
19218         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
19219         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
19220         return tag_ptr(ret_conv, true);
19221 }
19222
19223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
19224         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
19225         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
19226         return tag_ptr(ret_conv, true);
19227 }
19228
19229 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19230         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(o);
19231         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
19232         return ret_conv;
19233 }
19234
19235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19236         if (!ptr_is_owned(_res)) return;
19237         void* _res_ptr = untag_ptr(_res);
19238         CHECK_ACCESS(_res_ptr);
19239         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
19240         FREE(untag_ptr(_res));
19241         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
19242 }
19243
19244 static inline uint64_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
19245         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
19246         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
19247         return tag_ptr(ret_conv, true);
19248 }
19249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19250         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(arg);
19251         int64_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
19252         return ret_conv;
19253 }
19254
19255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19256         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(orig);
19257         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
19258         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
19259         return tag_ptr(ret_conv, true);
19260 }
19261
19262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19263         LDKSecretKey o_ref;
19264         CHECK((*env)->GetArrayLength(env, o) == 32);
19265         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
19266         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
19267         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
19268         return tag_ptr(ret_conv, true);
19269 }
19270
19271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1err(JNIEnv *env, jclass clz) {
19272         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
19273         *ret_conv = CResult_SecretKeyNoneZ_err();
19274         return tag_ptr(ret_conv, true);
19275 }
19276
19277 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19278         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(o);
19279         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
19280         return ret_conv;
19281 }
19282
19283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19284         if (!ptr_is_owned(_res)) return;
19285         void* _res_ptr = untag_ptr(_res);
19286         CHECK_ACCESS(_res_ptr);
19287         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
19288         FREE(untag_ptr(_res));
19289         CResult_SecretKeyNoneZ_free(_res_conv);
19290 }
19291
19292 static inline uint64_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
19293         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
19294         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
19295         return tag_ptr(ret_conv, true);
19296 }
19297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19298         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(arg);
19299         int64_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
19300         return ret_conv;
19301 }
19302
19303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19304         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(orig);
19305         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
19306         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
19307         return tag_ptr(ret_conv, true);
19308 }
19309
19310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19311         void* o_ptr = untag_ptr(o);
19312         CHECK_ACCESS(o_ptr);
19313         LDKBigEndianScalar o_conv = *(LDKBigEndianScalar*)(o_ptr);
19314         // WARNING: we may need a move here but no clone is available for LDKBigEndianScalar
19315         LDKCOption_ScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
19316         *ret_copy = COption_ScalarZ_some(o_conv);
19317         int64_t ret_ref = tag_ptr(ret_copy, true);
19318         return ret_ref;
19319 }
19320
19321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1none(JNIEnv *env, jclass clz) {
19322         LDKCOption_ScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
19323         *ret_copy = COption_ScalarZ_none();
19324         int64_t ret_ref = tag_ptr(ret_copy, true);
19325         return ret_ref;
19326 }
19327
19328 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19329         if (!ptr_is_owned(_res)) return;
19330         void* _res_ptr = untag_ptr(_res);
19331         CHECK_ACCESS(_res_ptr);
19332         LDKCOption_ScalarZ _res_conv = *(LDKCOption_ScalarZ*)(_res_ptr);
19333         FREE(untag_ptr(_res));
19334         COption_ScalarZ_free(_res_conv);
19335 }
19336
19337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19338         LDKThirtyTwoBytes o_ref;
19339         CHECK((*env)->GetArrayLength(env, o) == 32);
19340         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19341         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
19342         *ret_conv = CResult_SharedSecretNoneZ_ok(o_ref);
19343         return tag_ptr(ret_conv, true);
19344 }
19345
19346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1err(JNIEnv *env, jclass clz) {
19347         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
19348         *ret_conv = CResult_SharedSecretNoneZ_err();
19349         return tag_ptr(ret_conv, true);
19350 }
19351
19352 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19353         LDKCResult_SharedSecretNoneZ* o_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(o);
19354         jboolean ret_conv = CResult_SharedSecretNoneZ_is_ok(o_conv);
19355         return ret_conv;
19356 }
19357
19358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19359         if (!ptr_is_owned(_res)) return;
19360         void* _res_ptr = untag_ptr(_res);
19361         CHECK_ACCESS(_res_ptr);
19362         LDKCResult_SharedSecretNoneZ _res_conv = *(LDKCResult_SharedSecretNoneZ*)(_res_ptr);
19363         FREE(untag_ptr(_res));
19364         CResult_SharedSecretNoneZ_free(_res_conv);
19365 }
19366
19367 static inline uint64_t CResult_SharedSecretNoneZ_clone_ptr(LDKCResult_SharedSecretNoneZ *NONNULL_PTR arg) {
19368         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
19369         *ret_conv = CResult_SharedSecretNoneZ_clone(arg);
19370         return tag_ptr(ret_conv, true);
19371 }
19372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19373         LDKCResult_SharedSecretNoneZ* arg_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(arg);
19374         int64_t ret_conv = CResult_SharedSecretNoneZ_clone_ptr(arg_conv);
19375         return ret_conv;
19376 }
19377
19378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19379         LDKCResult_SharedSecretNoneZ* orig_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(orig);
19380         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
19381         *ret_conv = CResult_SharedSecretNoneZ_clone(orig_conv);
19382         return tag_ptr(ret_conv, true);
19383 }
19384
19385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19386         void* o_ptr = untag_ptr(o);
19387         CHECK_ACCESS(o_ptr);
19388         LDKSign o_conv = *(LDKSign*)(o_ptr);
19389         if (o_conv.free == LDKSign_JCalls_free) {
19390                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19391                 LDKSign_JCalls_cloned(&o_conv);
19392         }
19393         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
19394         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
19395         return tag_ptr(ret_conv, true);
19396 }
19397
19398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19399         LDKDecodeError e_conv;
19400         e_conv.inner = untag_ptr(e);
19401         e_conv.is_owned = ptr_is_owned(e);
19402         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19403         e_conv = DecodeError_clone(&e_conv);
19404         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
19405         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
19406         return tag_ptr(ret_conv, true);
19407 }
19408
19409 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19410         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(o);
19411         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
19412         return ret_conv;
19413 }
19414
19415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19416         if (!ptr_is_owned(_res)) return;
19417         void* _res_ptr = untag_ptr(_res);
19418         CHECK_ACCESS(_res_ptr);
19419         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
19420         FREE(untag_ptr(_res));
19421         CResult_SignDecodeErrorZ_free(_res_conv);
19422 }
19423
19424 static inline uint64_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
19425         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
19426         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
19427         return tag_ptr(ret_conv, true);
19428 }
19429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19430         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(arg);
19431         int64_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
19432         return ret_conv;
19433 }
19434
19435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19436         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(orig);
19437         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
19438         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
19439         return tag_ptr(ret_conv, true);
19440 }
19441
19442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u5Z_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19443         LDKCVec_u5Z _res_constr;
19444         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19445         if (_res_constr.datalen > 0)
19446                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
19447         else
19448                 _res_constr.data = NULL;
19449         int8_t* _res_vals = (*env)->GetByteArrayElements (env, _res, NULL);
19450         for (size_t h = 0; h < _res_constr.datalen; h++) {
19451                 int8_t _res_conv_7 = _res_vals[h];
19452                 
19453                 _res_constr.data[h] = (LDKu5){ ._0 = _res_conv_7 };
19454         }
19455         (*env)->ReleaseByteArrayElements(env, _res, _res_vals, 0);
19456         CVec_u5Z_free(_res_constr);
19457 }
19458
19459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19460         LDKRecoverableSignature o_ref;
19461         CHECK((*env)->GetArrayLength(env, o) == 68);
19462         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
19463         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19464         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
19465         return tag_ptr(ret_conv, true);
19466 }
19467
19468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
19469         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19470         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
19471         return tag_ptr(ret_conv, true);
19472 }
19473
19474 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19475         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(o);
19476         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
19477         return ret_conv;
19478 }
19479
19480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19481         if (!ptr_is_owned(_res)) return;
19482         void* _res_ptr = untag_ptr(_res);
19483         CHECK_ACCESS(_res_ptr);
19484         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
19485         FREE(untag_ptr(_res));
19486         CResult_RecoverableSignatureNoneZ_free(_res_conv);
19487 }
19488
19489 static inline uint64_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
19490         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19491         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
19492         return tag_ptr(ret_conv, true);
19493 }
19494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19495         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(arg);
19496         int64_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
19497         return ret_conv;
19498 }
19499
19500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19501         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(orig);
19502         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
19503         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
19504         return tag_ptr(ret_conv, true);
19505 }
19506
19507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
19508         LDKCVec_u8Z _res_ref;
19509         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
19510         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
19511         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
19512         CVec_u8Z_free(_res_ref);
19513 }
19514
19515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19516         LDKCVec_CVec_u8ZZ _res_constr;
19517         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19518         if (_res_constr.datalen > 0)
19519                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
19520         else
19521                 _res_constr.data = NULL;
19522         for (size_t i = 0; i < _res_constr.datalen; i++) {
19523                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19524                 LDKCVec_u8Z _res_conv_8_ref;
19525                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
19526                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
19527                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
19528                 _res_constr.data[i] = _res_conv_8_ref;
19529         }
19530         CVec_CVec_u8ZZ_free(_res_constr);
19531 }
19532
19533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
19534         LDKCVec_CVec_u8ZZ o_constr;
19535         o_constr.datalen = (*env)->GetArrayLength(env, o);
19536         if (o_constr.datalen > 0)
19537                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
19538         else
19539                 o_constr.data = NULL;
19540         for (size_t i = 0; i < o_constr.datalen; i++) {
19541                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
19542                 LDKCVec_u8Z o_conv_8_ref;
19543                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
19544                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
19545                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
19546                 o_constr.data[i] = o_conv_8_ref;
19547         }
19548         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19549         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
19550         return tag_ptr(ret_conv, true);
19551 }
19552
19553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
19554         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19555         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
19556         return tag_ptr(ret_conv, true);
19557 }
19558
19559 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19560         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(o);
19561         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
19562         return ret_conv;
19563 }
19564
19565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19566         if (!ptr_is_owned(_res)) return;
19567         void* _res_ptr = untag_ptr(_res);
19568         CHECK_ACCESS(_res_ptr);
19569         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
19570         FREE(untag_ptr(_res));
19571         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
19572 }
19573
19574 static inline uint64_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
19575         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19576         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
19577         return tag_ptr(ret_conv, true);
19578 }
19579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19580         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(arg);
19581         int64_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
19582         return ret_conv;
19583 }
19584
19585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19586         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(orig);
19587         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
19588         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
19589         return tag_ptr(ret_conv, true);
19590 }
19591
19592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19593         LDKInMemorySigner o_conv;
19594         o_conv.inner = untag_ptr(o);
19595         o_conv.is_owned = ptr_is_owned(o);
19596         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19597         o_conv = InMemorySigner_clone(&o_conv);
19598         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19599         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
19600         return tag_ptr(ret_conv, true);
19601 }
19602
19603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19604         LDKDecodeError e_conv;
19605         e_conv.inner = untag_ptr(e);
19606         e_conv.is_owned = ptr_is_owned(e);
19607         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19608         e_conv = DecodeError_clone(&e_conv);
19609         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19610         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
19611         return tag_ptr(ret_conv, true);
19612 }
19613
19614 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19615         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(o);
19616         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
19617         return ret_conv;
19618 }
19619
19620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19621         if (!ptr_is_owned(_res)) return;
19622         void* _res_ptr = untag_ptr(_res);
19623         CHECK_ACCESS(_res_ptr);
19624         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
19625         FREE(untag_ptr(_res));
19626         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
19627 }
19628
19629 static inline uint64_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
19630         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19631         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
19632         return tag_ptr(ret_conv, true);
19633 }
19634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19635         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(arg);
19636         int64_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
19637         return ret_conv;
19638 }
19639
19640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19641         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(orig);
19642         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
19643         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
19644         return tag_ptr(ret_conv, true);
19645 }
19646
19647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19648         LDKCVec_TxOutZ _res_constr;
19649         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19650         if (_res_constr.datalen > 0)
19651                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
19652         else
19653                 _res_constr.data = NULL;
19654         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19655         for (size_t h = 0; h < _res_constr.datalen; h++) {
19656                 int64_t _res_conv_7 = _res_vals[h];
19657                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
19658                 CHECK_ACCESS(_res_conv_7_ptr);
19659                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
19660                 FREE(untag_ptr(_res_conv_7));
19661                 _res_constr.data[h] = _res_conv_7_conv;
19662         }
19663         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19664         CVec_TxOutZ_free(_res_constr);
19665 }
19666
19667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19668         LDKTransaction o_ref;
19669         o_ref.datalen = (*env)->GetArrayLength(env, o);
19670         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
19671         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
19672         o_ref.data_is_owned = true;
19673         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19674         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
19675         return tag_ptr(ret_conv, true);
19676 }
19677
19678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
19679         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19680         *ret_conv = CResult_TransactionNoneZ_err();
19681         return tag_ptr(ret_conv, true);
19682 }
19683
19684 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19685         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(o);
19686         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
19687         return ret_conv;
19688 }
19689
19690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19691         if (!ptr_is_owned(_res)) return;
19692         void* _res_ptr = untag_ptr(_res);
19693         CHECK_ACCESS(_res_ptr);
19694         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
19695         FREE(untag_ptr(_res));
19696         CResult_TransactionNoneZ_free(_res_conv);
19697 }
19698
19699 static inline uint64_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
19700         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19701         *ret_conv = CResult_TransactionNoneZ_clone(arg);
19702         return tag_ptr(ret_conv, true);
19703 }
19704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19705         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(arg);
19706         int64_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
19707         return ret_conv;
19708 }
19709
19710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19711         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(orig);
19712         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
19713         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
19714         return tag_ptr(ret_conv, true);
19715 }
19716
19717 static inline uint64_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
19718         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
19719         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
19720         return tag_ptr(ret_conv, true);
19721 }
19722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19723         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(arg);
19724         int64_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
19725         return ret_conv;
19726 }
19727
19728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19729         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(orig);
19730         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
19731         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
19732         return tag_ptr(ret_conv, true);
19733 }
19734
19735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
19736         LDKThirtyTwoBytes a_ref;
19737         CHECK((*env)->GetArrayLength(env, a) == 32);
19738         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19739         LDKChannelMonitor b_conv;
19740         b_conv.inner = untag_ptr(b);
19741         b_conv.is_owned = ptr_is_owned(b);
19742         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
19743         b_conv = ChannelMonitor_clone(&b_conv);
19744         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
19745         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
19746         return tag_ptr(ret_conv, true);
19747 }
19748
19749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19750         if (!ptr_is_owned(_res)) return;
19751         void* _res_ptr = untag_ptr(_res);
19752         CHECK_ACCESS(_res_ptr);
19753         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
19754         FREE(untag_ptr(_res));
19755         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
19756 }
19757
19758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19759         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
19760         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19761         if (_res_constr.datalen > 0)
19762                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
19763         else
19764                 _res_constr.data = NULL;
19765         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19766         for (size_t j = 0; j < _res_constr.datalen; j++) {
19767                 int64_t _res_conv_35 = _res_vals[j];
19768                 void* _res_conv_35_ptr = untag_ptr(_res_conv_35);
19769                 CHECK_ACCESS(_res_conv_35_ptr);
19770                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
19771                 FREE(untag_ptr(_res_conv_35));
19772                 _res_constr.data[j] = _res_conv_35_conv;
19773         }
19774         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19775         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
19776 }
19777
19778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
19779         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
19780         o_constr.datalen = (*env)->GetArrayLength(env, o);
19781         if (o_constr.datalen > 0)
19782                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
19783         else
19784                 o_constr.data = NULL;
19785         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
19786         for (size_t j = 0; j < o_constr.datalen; j++) {
19787                 int64_t o_conv_35 = o_vals[j];
19788                 void* o_conv_35_ptr = untag_ptr(o_conv_35);
19789                 CHECK_ACCESS(o_conv_35_ptr);
19790                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
19791                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o_conv_35));
19792                 o_constr.data[j] = o_conv_35_conv;
19793         }
19794         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
19795         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
19796         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
19797         return tag_ptr(ret_conv, true);
19798 }
19799
19800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
19801         LDKIOError e_conv = LDKIOError_from_java(env, e);
19802         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
19803         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
19804         return tag_ptr(ret_conv, true);
19805 }
19806
19807 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19808         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(o);
19809         jboolean ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
19810         return ret_conv;
19811 }
19812
19813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19814         if (!ptr_is_owned(_res)) return;
19815         void* _res_ptr = untag_ptr(_res);
19816         CHECK_ACCESS(_res_ptr);
19817         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
19818         FREE(untag_ptr(_res));
19819         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
19820 }
19821
19822 static inline uint64_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
19823         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
19824         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
19825         return tag_ptr(ret_conv, true);
19826 }
19827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19828         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(arg);
19829         int64_t ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
19830         return ret_conv;
19831 }
19832
19833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19834         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(orig);
19835         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
19836         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
19837         return tag_ptr(ret_conv, true);
19838 }
19839
19840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
19841         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19842         *ret_copy = COption_u16Z_some(o);
19843         int64_t ret_ref = tag_ptr(ret_copy, true);
19844         return ret_ref;
19845 }
19846
19847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
19848         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19849         *ret_copy = COption_u16Z_none();
19850         int64_t ret_ref = tag_ptr(ret_copy, true);
19851         return ret_ref;
19852 }
19853
19854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
19855         if (!ptr_is_owned(_res)) return;
19856         void* _res_ptr = untag_ptr(_res);
19857         CHECK_ACCESS(_res_ptr);
19858         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
19859         FREE(untag_ptr(_res));
19860         COption_u16Z_free(_res_conv);
19861 }
19862
19863 static inline uint64_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
19864         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19865         *ret_copy = COption_u16Z_clone(arg);
19866         int64_t ret_ref = tag_ptr(ret_copy, true);
19867         return ret_ref;
19868 }
19869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19870         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)untag_ptr(arg);
19871         int64_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
19872         return ret_conv;
19873 }
19874
19875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19876         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)untag_ptr(orig);
19877         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
19878         *ret_copy = COption_u16Z_clone(orig_conv);
19879         int64_t ret_ref = tag_ptr(ret_copy, true);
19880         return ret_ref;
19881 }
19882
19883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
19884         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19885         *ret_conv = CResult_NoneAPIErrorZ_ok();
19886         return tag_ptr(ret_conv, true);
19887 }
19888
19889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19890         void* e_ptr = untag_ptr(e);
19891         CHECK_ACCESS(e_ptr);
19892         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19893         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
19894         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19895         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
19896         return tag_ptr(ret_conv, true);
19897 }
19898
19899 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19900         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(o);
19901         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
19902         return ret_conv;
19903 }
19904
19905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19906         if (!ptr_is_owned(_res)) return;
19907         void* _res_ptr = untag_ptr(_res);
19908         CHECK_ACCESS(_res_ptr);
19909         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
19910         FREE(untag_ptr(_res));
19911         CResult_NoneAPIErrorZ_free(_res_conv);
19912 }
19913
19914 static inline uint64_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
19915         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19916         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
19917         return tag_ptr(ret_conv, true);
19918 }
19919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19920         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(arg);
19921         int64_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
19922         return ret_conv;
19923 }
19924
19925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19926         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(orig);
19927         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
19928         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
19929         return tag_ptr(ret_conv, true);
19930 }
19931
19932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19933         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
19934         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19935         if (_res_constr.datalen > 0)
19936                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
19937         else
19938                 _res_constr.data = NULL;
19939         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19940         for (size_t w = 0; w < _res_constr.datalen; w++) {
19941                 int64_t _res_conv_22 = _res_vals[w];
19942                 void* _res_conv_22_ptr = untag_ptr(_res_conv_22);
19943                 CHECK_ACCESS(_res_conv_22_ptr);
19944                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
19945                 FREE(untag_ptr(_res_conv_22));
19946                 _res_constr.data[w] = _res_conv_22_conv;
19947         }
19948         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19949         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
19950 }
19951
19952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19953         LDKCVec_APIErrorZ _res_constr;
19954         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19955         if (_res_constr.datalen > 0)
19956                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
19957         else
19958                 _res_constr.data = NULL;
19959         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19960         for (size_t k = 0; k < _res_constr.datalen; k++) {
19961                 int64_t _res_conv_10 = _res_vals[k];
19962                 void* _res_conv_10_ptr = untag_ptr(_res_conv_10);
19963                 CHECK_ACCESS(_res_conv_10_ptr);
19964                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
19965                 FREE(untag_ptr(_res_conv_10));
19966                 _res_constr.data[k] = _res_conv_10_conv;
19967         }
19968         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19969         CVec_APIErrorZ_free(_res_constr);
19970 }
19971
19972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19973         LDKThirtyTwoBytes o_ref;
19974         CHECK((*env)->GetArrayLength(env, o) == 32);
19975         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
19976         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19977         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
19978         return tag_ptr(ret_conv, true);
19979 }
19980
19981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19982         void* e_ptr = untag_ptr(e);
19983         CHECK_ACCESS(e_ptr);
19984         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
19985         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
19986         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
19987         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
19988         return tag_ptr(ret_conv, true);
19989 }
19990
19991 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19992         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(o);
19993         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
19994         return ret_conv;
19995 }
19996
19997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19998         if (!ptr_is_owned(_res)) return;
19999         void* _res_ptr = untag_ptr(_res);
20000         CHECK_ACCESS(_res_ptr);
20001         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
20002         FREE(untag_ptr(_res));
20003         CResult__u832APIErrorZ_free(_res_conv);
20004 }
20005
20006 static inline uint64_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
20007         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20008         *ret_conv = CResult__u832APIErrorZ_clone(arg);
20009         return tag_ptr(ret_conv, true);
20010 }
20011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20012         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(arg);
20013         int64_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
20014         return ret_conv;
20015 }
20016
20017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20018         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(orig);
20019         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20020         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
20021         return tag_ptr(ret_conv, true);
20022 }
20023
20024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20025         LDKThirtyTwoBytes o_ref;
20026         CHECK((*env)->GetArrayLength(env, o) == 32);
20027         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20028         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
20029         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
20030         return tag_ptr(ret_conv, true);
20031 }
20032
20033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20034         void* e_ptr = untag_ptr(e);
20035         CHECK_ACCESS(e_ptr);
20036         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
20037         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
20038         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
20039         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
20040         return tag_ptr(ret_conv, true);
20041 }
20042
20043 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20044         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(o);
20045         jboolean ret_conv = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
20046         return ret_conv;
20047 }
20048
20049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20050         if (!ptr_is_owned(_res)) return;
20051         void* _res_ptr = untag_ptr(_res);
20052         CHECK_ACCESS(_res_ptr);
20053         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
20054         FREE(untag_ptr(_res));
20055         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
20056 }
20057
20058 static inline uint64_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
20059         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
20060         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
20061         return tag_ptr(ret_conv, true);
20062 }
20063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20064         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(arg);
20065         int64_t ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
20066         return ret_conv;
20067 }
20068
20069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20070         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)untag_ptr(orig);
20071         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
20072         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
20073         return tag_ptr(ret_conv, true);
20074 }
20075
20076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
20077         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20078         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
20079         return tag_ptr(ret_conv, true);
20080 }
20081
20082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20083         void* e_ptr = untag_ptr(e);
20084         CHECK_ACCESS(e_ptr);
20085         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
20086         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
20087         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20088         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
20089         return tag_ptr(ret_conv, true);
20090 }
20091
20092 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20093         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(o);
20094         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
20095         return ret_conv;
20096 }
20097
20098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20099         if (!ptr_is_owned(_res)) return;
20100         void* _res_ptr = untag_ptr(_res);
20101         CHECK_ACCESS(_res_ptr);
20102         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
20103         FREE(untag_ptr(_res));
20104         CResult_NonePaymentSendFailureZ_free(_res_conv);
20105 }
20106
20107 static inline uint64_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
20108         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20109         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
20110         return tag_ptr(ret_conv, true);
20111 }
20112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20113         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(arg);
20114         int64_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
20115         return ret_conv;
20116 }
20117
20118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20119         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(orig);
20120         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20121         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
20122         return tag_ptr(ret_conv, true);
20123 }
20124
20125 static inline uint64_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
20126         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
20127         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
20128         return tag_ptr(ret_conv, true);
20129 }
20130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20131         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(arg);
20132         int64_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
20133         return ret_conv;
20134 }
20135
20136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20137         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(orig);
20138         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
20139         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
20140         return tag_ptr(ret_conv, true);
20141 }
20142
20143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
20144         LDKThirtyTwoBytes a_ref;
20145         CHECK((*env)->GetArrayLength(env, a) == 32);
20146         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
20147         LDKThirtyTwoBytes b_ref;
20148         CHECK((*env)->GetArrayLength(env, b) == 32);
20149         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
20150         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
20151         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
20152         return tag_ptr(ret_conv, true);
20153 }
20154
20155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20156         if (!ptr_is_owned(_res)) return;
20157         void* _res_ptr = untag_ptr(_res);
20158         CHECK_ACCESS(_res_ptr);
20159         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
20160         FREE(untag_ptr(_res));
20161         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
20162 }
20163
20164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20165         void* o_ptr = untag_ptr(o);
20166         CHECK_ACCESS(o_ptr);
20167         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
20168         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(o));
20169         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
20170         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
20171         return tag_ptr(ret_conv, true);
20172 }
20173
20174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20175         void* e_ptr = untag_ptr(e);
20176         CHECK_ACCESS(e_ptr);
20177         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
20178         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
20179         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
20180         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
20181         return tag_ptr(ret_conv, true);
20182 }
20183
20184 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20185         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(o);
20186         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
20187         return ret_conv;
20188 }
20189
20190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20191         if (!ptr_is_owned(_res)) return;
20192         void* _res_ptr = untag_ptr(_res);
20193         CHECK_ACCESS(_res_ptr);
20194         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
20195         FREE(untag_ptr(_res));
20196         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
20197 }
20198
20199 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
20200         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
20201         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
20202         return tag_ptr(ret_conv, true);
20203 }
20204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20205         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(arg);
20206         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
20207         return ret_conv;
20208 }
20209
20210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20211         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(orig);
20212         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
20213         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
20214         return tag_ptr(ret_conv, true);
20215 }
20216
20217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ThirtyTwoBytesZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
20218         LDKCVec_ThirtyTwoBytesZ _res_constr;
20219         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20220         if (_res_constr.datalen > 0)
20221                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
20222         else
20223                 _res_constr.data = NULL;
20224         for (size_t i = 0; i < _res_constr.datalen; i++) {
20225                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
20226                 LDKThirtyTwoBytes _res_conv_8_ref;
20227                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
20228                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
20229                 _res_constr.data[i] = _res_conv_8_ref;
20230         }
20231         CVec_ThirtyTwoBytesZ_free(_res_constr);
20232 }
20233
20234 static inline uint64_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
20235         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
20236         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
20237         return tag_ptr(ret_conv, true);
20238 }
20239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20240         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(arg);
20241         int64_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
20242         return ret_conv;
20243 }
20244
20245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20246         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(orig);
20247         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
20248         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
20249         return tag_ptr(ret_conv, true);
20250 }
20251
20252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
20253         LDKThirtyTwoBytes a_ref;
20254         CHECK((*env)->GetArrayLength(env, a) == 32);
20255         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
20256         LDKThirtyTwoBytes b_ref;
20257         CHECK((*env)->GetArrayLength(env, b) == 32);
20258         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
20259         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
20260         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
20261         return tag_ptr(ret_conv, true);
20262 }
20263
20264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20265         if (!ptr_is_owned(_res)) return;
20266         void* _res_ptr = untag_ptr(_res);
20267         CHECK_ACCESS(_res_ptr);
20268         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
20269         FREE(untag_ptr(_res));
20270         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
20271 }
20272
20273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20274         void* o_ptr = untag_ptr(o);
20275         CHECK_ACCESS(o_ptr);
20276         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
20277         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
20278         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
20279         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
20280         return tag_ptr(ret_conv, true);
20281 }
20282
20283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
20284         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
20285         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
20286         return tag_ptr(ret_conv, true);
20287 }
20288
20289 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20290         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(o);
20291         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
20292         return ret_conv;
20293 }
20294
20295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20296         if (!ptr_is_owned(_res)) return;
20297         void* _res_ptr = untag_ptr(_res);
20298         CHECK_ACCESS(_res_ptr);
20299         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
20300         FREE(untag_ptr(_res));
20301         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
20302 }
20303
20304 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
20305         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
20306         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
20307         return tag_ptr(ret_conv, true);
20308 }
20309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20310         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(arg);
20311         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
20312         return ret_conv;
20313 }
20314
20315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20316         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(orig);
20317         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
20318         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
20319         return tag_ptr(ret_conv, true);
20320 }
20321
20322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20323         void* o_ptr = untag_ptr(o);
20324         CHECK_ACCESS(o_ptr);
20325         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
20326         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
20327         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
20328         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
20329         return tag_ptr(ret_conv, true);
20330 }
20331
20332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20333         void* e_ptr = untag_ptr(e);
20334         CHECK_ACCESS(e_ptr);
20335         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20336         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
20337         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
20338         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
20339         return tag_ptr(ret_conv, true);
20340 }
20341
20342 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20343         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(o);
20344         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
20345         return ret_conv;
20346 }
20347
20348 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20349         if (!ptr_is_owned(_res)) return;
20350         void* _res_ptr = untag_ptr(_res);
20351         CHECK_ACCESS(_res_ptr);
20352         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
20353         FREE(untag_ptr(_res));
20354         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
20355 }
20356
20357 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
20358         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
20359         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
20360         return tag_ptr(ret_conv, true);
20361 }
20362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20363         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(arg);
20364         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
20365         return ret_conv;
20366 }
20367
20368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20369         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(orig);
20370         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
20371         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
20372         return tag_ptr(ret_conv, true);
20373 }
20374
20375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20376         LDKThirtyTwoBytes o_ref;
20377         CHECK((*env)->GetArrayLength(env, o) == 32);
20378         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20379         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
20380         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
20381         return tag_ptr(ret_conv, true);
20382 }
20383
20384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
20385         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
20386         *ret_conv = CResult_PaymentSecretNoneZ_err();
20387         return tag_ptr(ret_conv, true);
20388 }
20389
20390 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20391         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(o);
20392         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
20393         return ret_conv;
20394 }
20395
20396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20397         if (!ptr_is_owned(_res)) return;
20398         void* _res_ptr = untag_ptr(_res);
20399         CHECK_ACCESS(_res_ptr);
20400         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
20401         FREE(untag_ptr(_res));
20402         CResult_PaymentSecretNoneZ_free(_res_conv);
20403 }
20404
20405 static inline uint64_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
20406         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
20407         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
20408         return tag_ptr(ret_conv, true);
20409 }
20410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20411         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(arg);
20412         int64_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
20413         return ret_conv;
20414 }
20415
20416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20417         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(orig);
20418         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
20419         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
20420         return tag_ptr(ret_conv, true);
20421 }
20422
20423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20424         LDKThirtyTwoBytes o_ref;
20425         CHECK((*env)->GetArrayLength(env, o) == 32);
20426         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20427         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20428         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
20429         return tag_ptr(ret_conv, true);
20430 }
20431
20432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20433         void* e_ptr = untag_ptr(e);
20434         CHECK_ACCESS(e_ptr);
20435         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20436         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
20437         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20438         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
20439         return tag_ptr(ret_conv, true);
20440 }
20441
20442 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20443         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(o);
20444         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
20445         return ret_conv;
20446 }
20447
20448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20449         if (!ptr_is_owned(_res)) return;
20450         void* _res_ptr = untag_ptr(_res);
20451         CHECK_ACCESS(_res_ptr);
20452         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
20453         FREE(untag_ptr(_res));
20454         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
20455 }
20456
20457 static inline uint64_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
20458         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20459         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
20460         return tag_ptr(ret_conv, true);
20461 }
20462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20463         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(arg);
20464         int64_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
20465         return ret_conv;
20466 }
20467
20468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20469         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(orig);
20470         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
20471         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
20472         return tag_ptr(ret_conv, true);
20473 }
20474
20475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20476         LDKThirtyTwoBytes o_ref;
20477         CHECK((*env)->GetArrayLength(env, o) == 32);
20478         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20479         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20480         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
20481         return tag_ptr(ret_conv, true);
20482 }
20483
20484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20485         void* e_ptr = untag_ptr(e);
20486         CHECK_ACCESS(e_ptr);
20487         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20488         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
20489         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20490         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
20491         return tag_ptr(ret_conv, true);
20492 }
20493
20494 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20495         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(o);
20496         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
20497         return ret_conv;
20498 }
20499
20500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20501         if (!ptr_is_owned(_res)) return;
20502         void* _res_ptr = untag_ptr(_res);
20503         CHECK_ACCESS(_res_ptr);
20504         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
20505         FREE(untag_ptr(_res));
20506         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
20507 }
20508
20509 static inline uint64_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
20510         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20511         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
20512         return tag_ptr(ret_conv, true);
20513 }
20514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20515         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(arg);
20516         int64_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
20517         return ret_conv;
20518 }
20519
20520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20521         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(orig);
20522         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
20523         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
20524         return tag_ptr(ret_conv, true);
20525 }
20526
20527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20528         LDKCounterpartyForwardingInfo o_conv;
20529         o_conv.inner = untag_ptr(o);
20530         o_conv.is_owned = ptr_is_owned(o);
20531         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20532         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
20533         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20534         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
20535         return tag_ptr(ret_conv, true);
20536 }
20537
20538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20539         LDKDecodeError e_conv;
20540         e_conv.inner = untag_ptr(e);
20541         e_conv.is_owned = ptr_is_owned(e);
20542         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20543         e_conv = DecodeError_clone(&e_conv);
20544         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20545         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
20546         return tag_ptr(ret_conv, true);
20547 }
20548
20549 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20550         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(o);
20551         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
20552         return ret_conv;
20553 }
20554
20555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20556         if (!ptr_is_owned(_res)) return;
20557         void* _res_ptr = untag_ptr(_res);
20558         CHECK_ACCESS(_res_ptr);
20559         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
20560         FREE(untag_ptr(_res));
20561         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
20562 }
20563
20564 static inline uint64_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
20565         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20566         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
20567         return tag_ptr(ret_conv, true);
20568 }
20569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20570         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(arg);
20571         int64_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
20572         return ret_conv;
20573 }
20574
20575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20576         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(orig);
20577         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
20578         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
20579         return tag_ptr(ret_conv, true);
20580 }
20581
20582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20583         LDKChannelCounterparty o_conv;
20584         o_conv.inner = untag_ptr(o);
20585         o_conv.is_owned = ptr_is_owned(o);
20586         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20587         o_conv = ChannelCounterparty_clone(&o_conv);
20588         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20589         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
20590         return tag_ptr(ret_conv, true);
20591 }
20592
20593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20594         LDKDecodeError e_conv;
20595         e_conv.inner = untag_ptr(e);
20596         e_conv.is_owned = ptr_is_owned(e);
20597         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20598         e_conv = DecodeError_clone(&e_conv);
20599         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20600         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
20601         return tag_ptr(ret_conv, true);
20602 }
20603
20604 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20605         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(o);
20606         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
20607         return ret_conv;
20608 }
20609
20610 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20611         if (!ptr_is_owned(_res)) return;
20612         void* _res_ptr = untag_ptr(_res);
20613         CHECK_ACCESS(_res_ptr);
20614         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
20615         FREE(untag_ptr(_res));
20616         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
20617 }
20618
20619 static inline uint64_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
20620         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20621         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
20622         return tag_ptr(ret_conv, true);
20623 }
20624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20625         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(arg);
20626         int64_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
20627         return ret_conv;
20628 }
20629
20630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20631         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(orig);
20632         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
20633         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
20634         return tag_ptr(ret_conv, true);
20635 }
20636
20637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20638         LDKChannelDetails o_conv;
20639         o_conv.inner = untag_ptr(o);
20640         o_conv.is_owned = ptr_is_owned(o);
20641         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20642         o_conv = ChannelDetails_clone(&o_conv);
20643         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20644         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
20645         return tag_ptr(ret_conv, true);
20646 }
20647
20648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20649         LDKDecodeError e_conv;
20650         e_conv.inner = untag_ptr(e);
20651         e_conv.is_owned = ptr_is_owned(e);
20652         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20653         e_conv = DecodeError_clone(&e_conv);
20654         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20655         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
20656         return tag_ptr(ret_conv, true);
20657 }
20658
20659 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20660         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(o);
20661         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
20662         return ret_conv;
20663 }
20664
20665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20666         if (!ptr_is_owned(_res)) return;
20667         void* _res_ptr = untag_ptr(_res);
20668         CHECK_ACCESS(_res_ptr);
20669         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
20670         FREE(untag_ptr(_res));
20671         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
20672 }
20673
20674 static inline uint64_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
20675         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20676         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
20677         return tag_ptr(ret_conv, true);
20678 }
20679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20680         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(arg);
20681         int64_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
20682         return ret_conv;
20683 }
20684
20685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20686         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(orig);
20687         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
20688         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
20689         return tag_ptr(ret_conv, true);
20690 }
20691
20692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20693         LDKPhantomRouteHints o_conv;
20694         o_conv.inner = untag_ptr(o);
20695         o_conv.is_owned = ptr_is_owned(o);
20696         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20697         o_conv = PhantomRouteHints_clone(&o_conv);
20698         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
20699         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
20700         return tag_ptr(ret_conv, true);
20701 }
20702
20703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20704         LDKDecodeError e_conv;
20705         e_conv.inner = untag_ptr(e);
20706         e_conv.is_owned = ptr_is_owned(e);
20707         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20708         e_conv = DecodeError_clone(&e_conv);
20709         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
20710         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
20711         return tag_ptr(ret_conv, true);
20712 }
20713
20714 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20715         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(o);
20716         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
20717         return ret_conv;
20718 }
20719
20720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20721         if (!ptr_is_owned(_res)) return;
20722         void* _res_ptr = untag_ptr(_res);
20723         CHECK_ACCESS(_res_ptr);
20724         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
20725         FREE(untag_ptr(_res));
20726         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
20727 }
20728
20729 static inline uint64_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
20730         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
20731         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
20732         return tag_ptr(ret_conv, true);
20733 }
20734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20735         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(arg);
20736         int64_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
20737         return ret_conv;
20738 }
20739
20740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20741         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(orig);
20742         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
20743         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
20744         return tag_ptr(ret_conv, true);
20745 }
20746
20747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20748         LDKCVec_ChannelMonitorZ _res_constr;
20749         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20750         if (_res_constr.datalen > 0)
20751                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
20752         else
20753                 _res_constr.data = NULL;
20754         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20755         for (size_t q = 0; q < _res_constr.datalen; q++) {
20756                 int64_t _res_conv_16 = _res_vals[q];
20757                 LDKChannelMonitor _res_conv_16_conv;
20758                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
20759                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
20760                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
20761                 _res_constr.data[q] = _res_conv_16_conv;
20762         }
20763         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20764         CVec_ChannelMonitorZ_free(_res_constr);
20765 }
20766
20767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
20768         LDKThirtyTwoBytes a_ref;
20769         CHECK((*env)->GetArrayLength(env, a) == 32);
20770         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
20771         LDKChannelManager b_conv;
20772         b_conv.inner = untag_ptr(b);
20773         b_conv.is_owned = ptr_is_owned(b);
20774         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
20775         // WARNING: we need a move here but no clone is available for LDKChannelManager
20776         
20777         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
20778         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
20779         return tag_ptr(ret_conv, true);
20780 }
20781
20782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20783         if (!ptr_is_owned(_res)) return;
20784         void* _res_ptr = untag_ptr(_res);
20785         CHECK_ACCESS(_res_ptr);
20786         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
20787         FREE(untag_ptr(_res));
20788         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
20789 }
20790
20791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20792         void* o_ptr = untag_ptr(o);
20793         CHECK_ACCESS(o_ptr);
20794         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
20795         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
20796         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
20797         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
20798         return tag_ptr(ret_conv, true);
20799 }
20800
20801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20802         LDKDecodeError e_conv;
20803         e_conv.inner = untag_ptr(e);
20804         e_conv.is_owned = ptr_is_owned(e);
20805         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20806         e_conv = DecodeError_clone(&e_conv);
20807         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
20808         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
20809         return tag_ptr(ret_conv, true);
20810 }
20811
20812 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20813         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(o);
20814         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
20815         return ret_conv;
20816 }
20817
20818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20819         if (!ptr_is_owned(_res)) return;
20820         void* _res_ptr = untag_ptr(_res);
20821         CHECK_ACCESS(_res_ptr);
20822         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
20823         FREE(untag_ptr(_res));
20824         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
20825 }
20826
20827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20828         LDKChannelConfig o_conv;
20829         o_conv.inner = untag_ptr(o);
20830         o_conv.is_owned = ptr_is_owned(o);
20831         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20832         o_conv = ChannelConfig_clone(&o_conv);
20833         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20834         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
20835         return tag_ptr(ret_conv, true);
20836 }
20837
20838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20839         LDKDecodeError e_conv;
20840         e_conv.inner = untag_ptr(e);
20841         e_conv.is_owned = ptr_is_owned(e);
20842         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20843         e_conv = DecodeError_clone(&e_conv);
20844         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20845         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
20846         return tag_ptr(ret_conv, true);
20847 }
20848
20849 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20850         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(o);
20851         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
20852         return ret_conv;
20853 }
20854
20855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20856         if (!ptr_is_owned(_res)) return;
20857         void* _res_ptr = untag_ptr(_res);
20858         CHECK_ACCESS(_res_ptr);
20859         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
20860         FREE(untag_ptr(_res));
20861         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
20862 }
20863
20864 static inline uint64_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
20865         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20866         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
20867         return tag_ptr(ret_conv, true);
20868 }
20869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20870         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(arg);
20871         int64_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
20872         return ret_conv;
20873 }
20874
20875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20876         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(orig);
20877         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20878         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
20879         return tag_ptr(ret_conv, true);
20880 }
20881
20882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20883         LDKOutPoint o_conv;
20884         o_conv.inner = untag_ptr(o);
20885         o_conv.is_owned = ptr_is_owned(o);
20886         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20887         o_conv = OutPoint_clone(&o_conv);
20888         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20889         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
20890         return tag_ptr(ret_conv, true);
20891 }
20892
20893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20894         LDKDecodeError e_conv;
20895         e_conv.inner = untag_ptr(e);
20896         e_conv.is_owned = ptr_is_owned(e);
20897         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
20898         e_conv = DecodeError_clone(&e_conv);
20899         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20900         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
20901         return tag_ptr(ret_conv, true);
20902 }
20903
20904 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20905         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(o);
20906         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
20907         return ret_conv;
20908 }
20909
20910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20911         if (!ptr_is_owned(_res)) return;
20912         void* _res_ptr = untag_ptr(_res);
20913         CHECK_ACCESS(_res_ptr);
20914         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
20915         FREE(untag_ptr(_res));
20916         CResult_OutPointDecodeErrorZ_free(_res_conv);
20917 }
20918
20919 static inline uint64_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
20920         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20921         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
20922         return tag_ptr(ret_conv, true);
20923 }
20924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20925         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(arg);
20926         int64_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
20927         return ret_conv;
20928 }
20929
20930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20931         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(orig);
20932         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
20933         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
20934         return tag_ptr(ret_conv, true);
20935 }
20936
20937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20938         void* o_ptr = untag_ptr(o);
20939         CHECK_ACCESS(o_ptr);
20940         LDKType o_conv = *(LDKType*)(o_ptr);
20941         if (o_conv.free == LDKType_JCalls_free) {
20942                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20943                 LDKType_JCalls_cloned(&o_conv);
20944         }
20945         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20946         *ret_copy = COption_TypeZ_some(o_conv);
20947         int64_t ret_ref = tag_ptr(ret_copy, true);
20948         return ret_ref;
20949 }
20950
20951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
20952         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20953         *ret_copy = COption_TypeZ_none();
20954         int64_t ret_ref = tag_ptr(ret_copy, true);
20955         return ret_ref;
20956 }
20957
20958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20959         if (!ptr_is_owned(_res)) return;
20960         void* _res_ptr = untag_ptr(_res);
20961         CHECK_ACCESS(_res_ptr);
20962         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
20963         FREE(untag_ptr(_res));
20964         COption_TypeZ_free(_res_conv);
20965 }
20966
20967 static inline uint64_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
20968         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20969         *ret_copy = COption_TypeZ_clone(arg);
20970         int64_t ret_ref = tag_ptr(ret_copy, true);
20971         return ret_ref;
20972 }
20973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20974         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)untag_ptr(arg);
20975         int64_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
20976         return ret_conv;
20977 }
20978
20979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20980         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)untag_ptr(orig);
20981         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
20982         *ret_copy = COption_TypeZ_clone(orig_conv);
20983         int64_t ret_ref = tag_ptr(ret_copy, true);
20984         return ret_ref;
20985 }
20986
20987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20988         void* o_ptr = untag_ptr(o);
20989         CHECK_ACCESS(o_ptr);
20990         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
20991         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)untag_ptr(o));
20992         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
20993         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
20994         return tag_ptr(ret_conv, true);
20995 }
20996
20997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20998         LDKDecodeError e_conv;
20999         e_conv.inner = untag_ptr(e);
21000         e_conv.is_owned = ptr_is_owned(e);
21001         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21002         e_conv = DecodeError_clone(&e_conv);
21003         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
21004         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
21005         return tag_ptr(ret_conv, true);
21006 }
21007
21008 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21009         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(o);
21010         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
21011         return ret_conv;
21012 }
21013
21014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21015         if (!ptr_is_owned(_res)) return;
21016         void* _res_ptr = untag_ptr(_res);
21017         CHECK_ACCESS(_res_ptr);
21018         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
21019         FREE(untag_ptr(_res));
21020         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
21021 }
21022
21023 static inline uint64_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
21024         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
21025         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
21026         return tag_ptr(ret_conv, true);
21027 }
21028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21029         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(arg);
21030         int64_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
21031         return ret_conv;
21032 }
21033
21034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21035         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(orig);
21036         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
21037         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
21038         return tag_ptr(ret_conv, true);
21039 }
21040
21041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21042         LDKThirtyTwoBytes o_ref;
21043         CHECK((*env)->GetArrayLength(env, o) == 32);
21044         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21045         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
21046         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
21047         return tag_ptr(ret_conv, true);
21048 }
21049
21050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21051         void* e_ptr = untag_ptr(e);
21052         CHECK_ACCESS(e_ptr);
21053         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
21054         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
21055         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
21056         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
21057         return tag_ptr(ret_conv, true);
21058 }
21059
21060 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21061         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(o);
21062         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
21063         return ret_conv;
21064 }
21065
21066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21067         if (!ptr_is_owned(_res)) return;
21068         void* _res_ptr = untag_ptr(_res);
21069         CHECK_ACCESS(_res_ptr);
21070         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
21071         FREE(untag_ptr(_res));
21072         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
21073 }
21074
21075 static inline uint64_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
21076         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
21077         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
21078         return tag_ptr(ret_conv, true);
21079 }
21080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21081         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(arg);
21082         int64_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
21083         return ret_conv;
21084 }
21085
21086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21087         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(orig);
21088         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
21089         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
21090         return tag_ptr(ret_conv, true);
21091 }
21092
21093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21094         LDKInFlightHtlcs o_conv;
21095         o_conv.inner = untag_ptr(o);
21096         o_conv.is_owned = ptr_is_owned(o);
21097         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21098         // WARNING: we need a move here but no clone is available for LDKInFlightHtlcs
21099         
21100         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
21101         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_ok(o_conv);
21102         return tag_ptr(ret_conv, true);
21103 }
21104
21105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21106         LDKDecodeError e_conv;
21107         e_conv.inner = untag_ptr(e);
21108         e_conv.is_owned = ptr_is_owned(e);
21109         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21110         e_conv = DecodeError_clone(&e_conv);
21111         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
21112         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_err(e_conv);
21113         return tag_ptr(ret_conv, true);
21114 }
21115
21116 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21117         LDKCResult_InFlightHtlcsDecodeErrorZ* o_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(o);
21118         jboolean ret_conv = CResult_InFlightHtlcsDecodeErrorZ_is_ok(o_conv);
21119         return ret_conv;
21120 }
21121
21122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21123         if (!ptr_is_owned(_res)) return;
21124         void* _res_ptr = untag_ptr(_res);
21125         CHECK_ACCESS(_res_ptr);
21126         LDKCResult_InFlightHtlcsDecodeErrorZ _res_conv = *(LDKCResult_InFlightHtlcsDecodeErrorZ*)(_res_ptr);
21127         FREE(untag_ptr(_res));
21128         CResult_InFlightHtlcsDecodeErrorZ_free(_res_conv);
21129 }
21130
21131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1ok(JNIEnv *env, jclass clz, jclass o) {
21132         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
21133         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
21134         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
21135         return tag_ptr(ret_conv, true);
21136 }
21137
21138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21139         void* e_ptr = untag_ptr(e);
21140         CHECK_ACCESS(e_ptr);
21141         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
21142         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
21143         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
21144         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
21145         return tag_ptr(ret_conv, true);
21146 }
21147
21148 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21149         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(o);
21150         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
21151         return ret_conv;
21152 }
21153
21154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21155         if (!ptr_is_owned(_res)) return;
21156         void* _res_ptr = untag_ptr(_res);
21157         CHECK_ACCESS(_res_ptr);
21158         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
21159         FREE(untag_ptr(_res));
21160         CResult_SiPrefixParseErrorZ_free(_res_conv);
21161 }
21162
21163 static inline uint64_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
21164         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
21165         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
21166         return tag_ptr(ret_conv, true);
21167 }
21168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21169         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(arg);
21170         int64_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
21171         return ret_conv;
21172 }
21173
21174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21175         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(orig);
21176         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
21177         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
21178         return tag_ptr(ret_conv, true);
21179 }
21180
21181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21182         LDKInvoice o_conv;
21183         o_conv.inner = untag_ptr(o);
21184         o_conv.is_owned = ptr_is_owned(o);
21185         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21186         o_conv = Invoice_clone(&o_conv);
21187         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
21188         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
21189         return tag_ptr(ret_conv, true);
21190 }
21191
21192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21193         void* e_ptr = untag_ptr(e);
21194         CHECK_ACCESS(e_ptr);
21195         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
21196         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)untag_ptr(e));
21197         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
21198         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
21199         return tag_ptr(ret_conv, true);
21200 }
21201
21202 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21203         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(o);
21204         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
21205         return ret_conv;
21206 }
21207
21208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21209         if (!ptr_is_owned(_res)) return;
21210         void* _res_ptr = untag_ptr(_res);
21211         CHECK_ACCESS(_res_ptr);
21212         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
21213         FREE(untag_ptr(_res));
21214         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
21215 }
21216
21217 static inline uint64_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
21218         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
21219         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
21220         return tag_ptr(ret_conv, true);
21221 }
21222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21223         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(arg);
21224         int64_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
21225         return ret_conv;
21226 }
21227
21228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21229         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(orig);
21230         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
21231         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
21232         return tag_ptr(ret_conv, true);
21233 }
21234
21235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21236         LDKSignedRawInvoice o_conv;
21237         o_conv.inner = untag_ptr(o);
21238         o_conv.is_owned = ptr_is_owned(o);
21239         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21240         o_conv = SignedRawInvoice_clone(&o_conv);
21241         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
21242         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
21243         return tag_ptr(ret_conv, true);
21244 }
21245
21246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21247         void* e_ptr = untag_ptr(e);
21248         CHECK_ACCESS(e_ptr);
21249         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
21250         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
21251         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
21252         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
21253         return tag_ptr(ret_conv, true);
21254 }
21255
21256 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21257         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(o);
21258         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
21259         return ret_conv;
21260 }
21261
21262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21263         if (!ptr_is_owned(_res)) return;
21264         void* _res_ptr = untag_ptr(_res);
21265         CHECK_ACCESS(_res_ptr);
21266         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
21267         FREE(untag_ptr(_res));
21268         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
21269 }
21270
21271 static inline uint64_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
21272         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
21273         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
21274         return tag_ptr(ret_conv, true);
21275 }
21276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21277         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(arg);
21278         int64_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
21279         return ret_conv;
21280 }
21281
21282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21283         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(orig);
21284         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
21285         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
21286         return tag_ptr(ret_conv, true);
21287 }
21288
21289 static inline uint64_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
21290         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
21291         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
21292         return tag_ptr(ret_conv, true);
21293 }
21294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21295         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(arg);
21296         int64_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
21297         return ret_conv;
21298 }
21299
21300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21301         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(orig);
21302         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
21303         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
21304         return tag_ptr(ret_conv, true);
21305 }
21306
21307 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) {
21308         LDKRawInvoice a_conv;
21309         a_conv.inner = untag_ptr(a);
21310         a_conv.is_owned = ptr_is_owned(a);
21311         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21312         a_conv = RawInvoice_clone(&a_conv);
21313         LDKThirtyTwoBytes b_ref;
21314         CHECK((*env)->GetArrayLength(env, b) == 32);
21315         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
21316         LDKInvoiceSignature c_conv;
21317         c_conv.inner = untag_ptr(c);
21318         c_conv.is_owned = ptr_is_owned(c);
21319         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
21320         c_conv = InvoiceSignature_clone(&c_conv);
21321         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
21322         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
21323         return tag_ptr(ret_conv, true);
21324 }
21325
21326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21327         if (!ptr_is_owned(_res)) return;
21328         void* _res_ptr = untag_ptr(_res);
21329         CHECK_ACCESS(_res_ptr);
21330         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
21331         FREE(untag_ptr(_res));
21332         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
21333 }
21334
21335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21336         LDKPayeePubKey o_conv;
21337         o_conv.inner = untag_ptr(o);
21338         o_conv.is_owned = ptr_is_owned(o);
21339         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21340         o_conv = PayeePubKey_clone(&o_conv);
21341         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
21342         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
21343         return tag_ptr(ret_conv, true);
21344 }
21345
21346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21347         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
21348         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
21349         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
21350         return tag_ptr(ret_conv, true);
21351 }
21352
21353 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21354         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(o);
21355         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
21356         return ret_conv;
21357 }
21358
21359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21360         if (!ptr_is_owned(_res)) return;
21361         void* _res_ptr = untag_ptr(_res);
21362         CHECK_ACCESS(_res_ptr);
21363         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
21364         FREE(untag_ptr(_res));
21365         CResult_PayeePubKeyErrorZ_free(_res_conv);
21366 }
21367
21368 static inline uint64_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
21369         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
21370         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
21371         return tag_ptr(ret_conv, true);
21372 }
21373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21374         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(arg);
21375         int64_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
21376         return ret_conv;
21377 }
21378
21379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21380         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(orig);
21381         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
21382         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
21383         return tag_ptr(ret_conv, true);
21384 }
21385
21386 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21387         LDKCVec_PrivateRouteZ _res_constr;
21388         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21389         if (_res_constr.datalen > 0)
21390                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
21391         else
21392                 _res_constr.data = NULL;
21393         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21394         for (size_t o = 0; o < _res_constr.datalen; o++) {
21395                 int64_t _res_conv_14 = _res_vals[o];
21396                 LDKPrivateRoute _res_conv_14_conv;
21397                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
21398                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
21399                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
21400                 _res_constr.data[o] = _res_conv_14_conv;
21401         }
21402         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21403         CVec_PrivateRouteZ_free(_res_constr);
21404 }
21405
21406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21407         LDKPositiveTimestamp o_conv;
21408         o_conv.inner = untag_ptr(o);
21409         o_conv.is_owned = ptr_is_owned(o);
21410         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21411         o_conv = PositiveTimestamp_clone(&o_conv);
21412         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
21413         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
21414         return tag_ptr(ret_conv, true);
21415 }
21416
21417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21418         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
21419         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
21420         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
21421         return tag_ptr(ret_conv, true);
21422 }
21423
21424 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21425         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(o);
21426         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
21427         return ret_conv;
21428 }
21429
21430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21431         if (!ptr_is_owned(_res)) return;
21432         void* _res_ptr = untag_ptr(_res);
21433         CHECK_ACCESS(_res_ptr);
21434         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
21435         FREE(untag_ptr(_res));
21436         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
21437 }
21438
21439 static inline uint64_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
21440         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
21441         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
21442         return tag_ptr(ret_conv, true);
21443 }
21444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21445         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(arg);
21446         int64_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
21447         return ret_conv;
21448 }
21449
21450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21451         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(orig);
21452         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
21453         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
21454         return tag_ptr(ret_conv, true);
21455 }
21456
21457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
21458         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21459         *ret_conv = CResult_NoneSemanticErrorZ_ok();
21460         return tag_ptr(ret_conv, true);
21461 }
21462
21463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21464         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
21465         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21466         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
21467         return tag_ptr(ret_conv, true);
21468 }
21469
21470 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21471         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(o);
21472         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
21473         return ret_conv;
21474 }
21475
21476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21477         if (!ptr_is_owned(_res)) return;
21478         void* _res_ptr = untag_ptr(_res);
21479         CHECK_ACCESS(_res_ptr);
21480         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
21481         FREE(untag_ptr(_res));
21482         CResult_NoneSemanticErrorZ_free(_res_conv);
21483 }
21484
21485 static inline uint64_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
21486         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21487         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
21488         return tag_ptr(ret_conv, true);
21489 }
21490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21491         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(arg);
21492         int64_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
21493         return ret_conv;
21494 }
21495
21496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21497         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(orig);
21498         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
21499         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
21500         return tag_ptr(ret_conv, true);
21501 }
21502
21503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21504         LDKInvoice o_conv;
21505         o_conv.inner = untag_ptr(o);
21506         o_conv.is_owned = ptr_is_owned(o);
21507         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21508         o_conv = Invoice_clone(&o_conv);
21509         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21510         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
21511         return tag_ptr(ret_conv, true);
21512 }
21513
21514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21515         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
21516         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21517         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
21518         return tag_ptr(ret_conv, true);
21519 }
21520
21521 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21522         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(o);
21523         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
21524         return ret_conv;
21525 }
21526
21527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21528         if (!ptr_is_owned(_res)) return;
21529         void* _res_ptr = untag_ptr(_res);
21530         CHECK_ACCESS(_res_ptr);
21531         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
21532         FREE(untag_ptr(_res));
21533         CResult_InvoiceSemanticErrorZ_free(_res_conv);
21534 }
21535
21536 static inline uint64_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
21537         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21538         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
21539         return tag_ptr(ret_conv, true);
21540 }
21541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21542         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(arg);
21543         int64_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
21544         return ret_conv;
21545 }
21546
21547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21548         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(orig);
21549         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
21550         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
21551         return tag_ptr(ret_conv, true);
21552 }
21553
21554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21555         LDKDescription o_conv;
21556         o_conv.inner = untag_ptr(o);
21557         o_conv.is_owned = ptr_is_owned(o);
21558         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21559         o_conv = Description_clone(&o_conv);
21560         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21561         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
21562         return tag_ptr(ret_conv, true);
21563 }
21564
21565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21566         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
21567         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21568         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
21569         return tag_ptr(ret_conv, true);
21570 }
21571
21572 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21573         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(o);
21574         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
21575         return ret_conv;
21576 }
21577
21578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21579         if (!ptr_is_owned(_res)) return;
21580         void* _res_ptr = untag_ptr(_res);
21581         CHECK_ACCESS(_res_ptr);
21582         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
21583         FREE(untag_ptr(_res));
21584         CResult_DescriptionCreationErrorZ_free(_res_conv);
21585 }
21586
21587 static inline uint64_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
21588         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21589         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
21590         return tag_ptr(ret_conv, true);
21591 }
21592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21593         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(arg);
21594         int64_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
21595         return ret_conv;
21596 }
21597
21598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21599         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(orig);
21600         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
21601         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
21602         return tag_ptr(ret_conv, true);
21603 }
21604
21605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21606         LDKPrivateRoute o_conv;
21607         o_conv.inner = untag_ptr(o);
21608         o_conv.is_owned = ptr_is_owned(o);
21609         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21610         o_conv = PrivateRoute_clone(&o_conv);
21611         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21612         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
21613         return tag_ptr(ret_conv, true);
21614 }
21615
21616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21617         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
21618         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21619         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
21620         return tag_ptr(ret_conv, true);
21621 }
21622
21623 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21624         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(o);
21625         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
21626         return ret_conv;
21627 }
21628
21629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21630         if (!ptr_is_owned(_res)) return;
21631         void* _res_ptr = untag_ptr(_res);
21632         CHECK_ACCESS(_res_ptr);
21633         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
21634         FREE(untag_ptr(_res));
21635         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
21636 }
21637
21638 static inline uint64_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
21639         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21640         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
21641         return tag_ptr(ret_conv, true);
21642 }
21643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21644         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(arg);
21645         int64_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
21646         return ret_conv;
21647 }
21648
21649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21650         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(orig);
21651         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
21652         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
21653         return tag_ptr(ret_conv, true);
21654 }
21655
21656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
21657         LDKStr o_conv = java_to_owned_str(env, o);
21658         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21659         *ret_conv = CResult_StringErrorZ_ok(o_conv);
21660         return tag_ptr(ret_conv, true);
21661 }
21662
21663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
21664         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
21665         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21666         *ret_conv = CResult_StringErrorZ_err(e_conv);
21667         return tag_ptr(ret_conv, true);
21668 }
21669
21670 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21671         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)untag_ptr(o);
21672         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
21673         return ret_conv;
21674 }
21675
21676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21677         if (!ptr_is_owned(_res)) return;
21678         void* _res_ptr = untag_ptr(_res);
21679         CHECK_ACCESS(_res_ptr);
21680         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
21681         FREE(untag_ptr(_res));
21682         CResult_StringErrorZ_free(_res_conv);
21683 }
21684
21685 static inline uint64_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
21686         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21687         *ret_conv = CResult_StringErrorZ_clone(arg);
21688         return tag_ptr(ret_conv, true);
21689 }
21690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21691         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)untag_ptr(arg);
21692         int64_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
21693         return ret_conv;
21694 }
21695
21696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21697         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)untag_ptr(orig);
21698         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
21699         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
21700         return tag_ptr(ret_conv, true);
21701 }
21702
21703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21704         LDKChannelMonitorUpdate o_conv;
21705         o_conv.inner = untag_ptr(o);
21706         o_conv.is_owned = ptr_is_owned(o);
21707         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21708         o_conv = ChannelMonitorUpdate_clone(&o_conv);
21709         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21710         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
21711         return tag_ptr(ret_conv, true);
21712 }
21713
21714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21715         LDKDecodeError e_conv;
21716         e_conv.inner = untag_ptr(e);
21717         e_conv.is_owned = ptr_is_owned(e);
21718         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21719         e_conv = DecodeError_clone(&e_conv);
21720         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21721         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
21722         return tag_ptr(ret_conv, true);
21723 }
21724
21725 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21726         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(o);
21727         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
21728         return ret_conv;
21729 }
21730
21731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21732         if (!ptr_is_owned(_res)) return;
21733         void* _res_ptr = untag_ptr(_res);
21734         CHECK_ACCESS(_res_ptr);
21735         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
21736         FREE(untag_ptr(_res));
21737         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
21738 }
21739
21740 static inline uint64_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
21741         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21742         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
21743         return tag_ptr(ret_conv, true);
21744 }
21745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21746         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(arg);
21747         int64_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
21748         return ret_conv;
21749 }
21750
21751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21752         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(orig);
21753         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21754         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
21755         return tag_ptr(ret_conv, true);
21756 }
21757
21758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
21759         void* o_ptr = untag_ptr(o);
21760         CHECK_ACCESS(o_ptr);
21761         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
21762         o_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(o));
21763         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
21764         *ret_copy = COption_MonitorEventZ_some(o_conv);
21765         int64_t ret_ref = tag_ptr(ret_copy, true);
21766         return ret_ref;
21767 }
21768
21769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
21770         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
21771         *ret_copy = COption_MonitorEventZ_none();
21772         int64_t ret_ref = tag_ptr(ret_copy, true);
21773         return ret_ref;
21774 }
21775
21776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21777         if (!ptr_is_owned(_res)) return;
21778         void* _res_ptr = untag_ptr(_res);
21779         CHECK_ACCESS(_res_ptr);
21780         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
21781         FREE(untag_ptr(_res));
21782         COption_MonitorEventZ_free(_res_conv);
21783 }
21784
21785 static inline uint64_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
21786         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
21787         *ret_copy = COption_MonitorEventZ_clone(arg);
21788         int64_t ret_ref = tag_ptr(ret_copy, true);
21789         return ret_ref;
21790 }
21791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21792         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)untag_ptr(arg);
21793         int64_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
21794         return ret_conv;
21795 }
21796
21797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21798         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)untag_ptr(orig);
21799         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
21800         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
21801         int64_t ret_ref = tag_ptr(ret_copy, true);
21802         return ret_ref;
21803 }
21804
21805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21806         void* o_ptr = untag_ptr(o);
21807         CHECK_ACCESS(o_ptr);
21808         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
21809         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)untag_ptr(o));
21810         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
21811         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
21812         return tag_ptr(ret_conv, true);
21813 }
21814
21815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21816         LDKDecodeError e_conv;
21817         e_conv.inner = untag_ptr(e);
21818         e_conv.is_owned = ptr_is_owned(e);
21819         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21820         e_conv = DecodeError_clone(&e_conv);
21821         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
21822         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
21823         return tag_ptr(ret_conv, true);
21824 }
21825
21826 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21827         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(o);
21828         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
21829         return ret_conv;
21830 }
21831
21832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21833         if (!ptr_is_owned(_res)) return;
21834         void* _res_ptr = untag_ptr(_res);
21835         CHECK_ACCESS(_res_ptr);
21836         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
21837         FREE(untag_ptr(_res));
21838         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
21839 }
21840
21841 static inline uint64_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
21842         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
21843         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
21844         return tag_ptr(ret_conv, true);
21845 }
21846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21847         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(arg);
21848         int64_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
21849         return ret_conv;
21850 }
21851
21852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21853         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(orig);
21854         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
21855         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
21856         return tag_ptr(ret_conv, true);
21857 }
21858
21859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21860         LDKHTLCUpdate o_conv;
21861         o_conv.inner = untag_ptr(o);
21862         o_conv.is_owned = ptr_is_owned(o);
21863         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21864         o_conv = HTLCUpdate_clone(&o_conv);
21865         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21866         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
21867         return tag_ptr(ret_conv, true);
21868 }
21869
21870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21871         LDKDecodeError e_conv;
21872         e_conv.inner = untag_ptr(e);
21873         e_conv.is_owned = ptr_is_owned(e);
21874         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
21875         e_conv = DecodeError_clone(&e_conv);
21876         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21877         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
21878         return tag_ptr(ret_conv, true);
21879 }
21880
21881 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21882         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(o);
21883         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
21884         return ret_conv;
21885 }
21886
21887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21888         if (!ptr_is_owned(_res)) return;
21889         void* _res_ptr = untag_ptr(_res);
21890         CHECK_ACCESS(_res_ptr);
21891         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
21892         FREE(untag_ptr(_res));
21893         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
21894 }
21895
21896 static inline uint64_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
21897         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21898         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
21899         return tag_ptr(ret_conv, true);
21900 }
21901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21902         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(arg);
21903         int64_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
21904         return ret_conv;
21905 }
21906
21907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21908         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(orig);
21909         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21910         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
21911         return tag_ptr(ret_conv, true);
21912 }
21913
21914 static inline uint64_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
21915         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
21916         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
21917         return tag_ptr(ret_conv, true);
21918 }
21919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21920         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(arg);
21921         int64_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
21922         return ret_conv;
21923 }
21924
21925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21926         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(orig);
21927         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
21928         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
21929         return tag_ptr(ret_conv, true);
21930 }
21931
21932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
21933         LDKOutPoint a_conv;
21934         a_conv.inner = untag_ptr(a);
21935         a_conv.is_owned = ptr_is_owned(a);
21936         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21937         a_conv = OutPoint_clone(&a_conv);
21938         LDKCVec_u8Z b_ref;
21939         b_ref.datalen = (*env)->GetArrayLength(env, b);
21940         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
21941         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
21942         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
21943         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
21944         return tag_ptr(ret_conv, true);
21945 }
21946
21947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21948         if (!ptr_is_owned(_res)) return;
21949         void* _res_ptr = untag_ptr(_res);
21950         CHECK_ACCESS(_res_ptr);
21951         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
21952         FREE(untag_ptr(_res));
21953         C2Tuple_OutPointScriptZ_free(_res_conv);
21954 }
21955
21956 static inline uint64_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
21957         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
21958         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
21959         return tag_ptr(ret_conv, true);
21960 }
21961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21962         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(arg);
21963         int64_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
21964         return ret_conv;
21965 }
21966
21967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21968         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(orig);
21969         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
21970         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
21971         return tag_ptr(ret_conv, true);
21972 }
21973
21974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
21975         LDKCVec_u8Z b_ref;
21976         b_ref.datalen = (*env)->GetArrayLength(env, b);
21977         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
21978         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
21979         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
21980         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
21981         return tag_ptr(ret_conv, true);
21982 }
21983
21984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21985         if (!ptr_is_owned(_res)) return;
21986         void* _res_ptr = untag_ptr(_res);
21987         CHECK_ACCESS(_res_ptr);
21988         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
21989         FREE(untag_ptr(_res));
21990         C2Tuple_u32ScriptZ_free(_res_conv);
21991 }
21992
21993 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21994         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
21995         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21996         if (_res_constr.datalen > 0)
21997                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
21998         else
21999                 _res_constr.data = NULL;
22000         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22001         for (size_t v = 0; v < _res_constr.datalen; v++) {
22002                 int64_t _res_conv_21 = _res_vals[v];
22003                 void* _res_conv_21_ptr = untag_ptr(_res_conv_21);
22004                 CHECK_ACCESS(_res_conv_21_ptr);
22005                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
22006                 FREE(untag_ptr(_res_conv_21));
22007                 _res_constr.data[v] = _res_conv_21_conv;
22008         }
22009         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22010         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
22011 }
22012
22013 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
22014         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22015         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
22016         return tag_ptr(ret_conv, true);
22017 }
22018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22019         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(arg);
22020         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
22021         return ret_conv;
22022 }
22023
22024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22025         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(orig);
22026         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22027         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
22028         return tag_ptr(ret_conv, true);
22029 }
22030
22031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
22032         LDKThirtyTwoBytes a_ref;
22033         CHECK((*env)->GetArrayLength(env, a) == 32);
22034         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
22035         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
22036         b_constr.datalen = (*env)->GetArrayLength(env, b);
22037         if (b_constr.datalen > 0)
22038                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
22039         else
22040                 b_constr.data = NULL;
22041         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
22042         for (size_t v = 0; v < b_constr.datalen; v++) {
22043                 int64_t b_conv_21 = b_vals[v];
22044                 void* b_conv_21_ptr = untag_ptr(b_conv_21);
22045                 CHECK_ACCESS(b_conv_21_ptr);
22046                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
22047                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)untag_ptr(b_conv_21));
22048                 b_constr.data[v] = b_conv_21_conv;
22049         }
22050         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
22051         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22052         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
22053         return tag_ptr(ret_conv, true);
22054 }
22055
22056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22057         if (!ptr_is_owned(_res)) return;
22058         void* _res_ptr = untag_ptr(_res);
22059         CHECK_ACCESS(_res_ptr);
22060         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
22061         FREE(untag_ptr(_res));
22062         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
22063 }
22064
22065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22066         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
22067         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22068         if (_res_constr.datalen > 0)
22069                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
22070         else
22071                 _res_constr.data = NULL;
22072         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22073         for (size_t o = 0; o < _res_constr.datalen; o++) {
22074                 int64_t _res_conv_40 = _res_vals[o];
22075                 void* _res_conv_40_ptr = untag_ptr(_res_conv_40);
22076                 CHECK_ACCESS(_res_conv_40_ptr);
22077                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
22078                 FREE(untag_ptr(_res_conv_40));
22079                 _res_constr.data[o] = _res_conv_40_conv;
22080         }
22081         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22082         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
22083 }
22084
22085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22086         LDKCVec_EventZ _res_constr;
22087         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22088         if (_res_constr.datalen > 0)
22089                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
22090         else
22091                 _res_constr.data = NULL;
22092         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22093         for (size_t h = 0; h < _res_constr.datalen; h++) {
22094                 int64_t _res_conv_7 = _res_vals[h];
22095                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
22096                 CHECK_ACCESS(_res_conv_7_ptr);
22097                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
22098                 FREE(untag_ptr(_res_conv_7));
22099                 _res_constr.data[h] = _res_conv_7_conv;
22100         }
22101         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22102         CVec_EventZ_free(_res_constr);
22103 }
22104
22105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
22106         LDKCVec_TransactionZ _res_constr;
22107         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22108         if (_res_constr.datalen > 0)
22109                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
22110         else
22111                 _res_constr.data = NULL;
22112         for (size_t i = 0; i < _res_constr.datalen; i++) {
22113                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
22114                 LDKTransaction _res_conv_8_ref;
22115                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
22116                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
22117                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
22118                 _res_conv_8_ref.data_is_owned = true;
22119                 _res_constr.data[i] = _res_conv_8_ref;
22120         }
22121         CVec_TransactionZ_free(_res_constr);
22122 }
22123
22124 static inline uint64_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
22125         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22126         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
22127         return tag_ptr(ret_conv, true);
22128 }
22129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22130         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(arg);
22131         int64_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
22132         return ret_conv;
22133 }
22134
22135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22136         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(orig);
22137         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22138         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
22139         return tag_ptr(ret_conv, true);
22140 }
22141
22142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
22143         void* b_ptr = untag_ptr(b);
22144         CHECK_ACCESS(b_ptr);
22145         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
22146         b_conv = TxOut_clone((LDKTxOut*)untag_ptr(b));
22147         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22148         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
22149         return tag_ptr(ret_conv, true);
22150 }
22151
22152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22153         if (!ptr_is_owned(_res)) return;
22154         void* _res_ptr = untag_ptr(_res);
22155         CHECK_ACCESS(_res_ptr);
22156         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
22157         FREE(untag_ptr(_res));
22158         C2Tuple_u32TxOutZ_free(_res_conv);
22159 }
22160
22161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22162         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
22163         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22164         if (_res_constr.datalen > 0)
22165                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
22166         else
22167                 _res_constr.data = NULL;
22168         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22169         for (size_t u = 0; u < _res_constr.datalen; u++) {
22170                 int64_t _res_conv_20 = _res_vals[u];
22171                 void* _res_conv_20_ptr = untag_ptr(_res_conv_20);
22172                 CHECK_ACCESS(_res_conv_20_ptr);
22173                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
22174                 FREE(untag_ptr(_res_conv_20));
22175                 _res_constr.data[u] = _res_conv_20_conv;
22176         }
22177         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22178         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
22179 }
22180
22181 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
22182         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22183         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
22184         return tag_ptr(ret_conv, true);
22185 }
22186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22187         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(arg);
22188         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
22189         return ret_conv;
22190 }
22191
22192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22193         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(orig);
22194         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22195         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
22196         return tag_ptr(ret_conv, true);
22197 }
22198
22199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
22200         LDKThirtyTwoBytes a_ref;
22201         CHECK((*env)->GetArrayLength(env, a) == 32);
22202         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
22203         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
22204         b_constr.datalen = (*env)->GetArrayLength(env, b);
22205         if (b_constr.datalen > 0)
22206                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
22207         else
22208                 b_constr.data = NULL;
22209         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
22210         for (size_t u = 0; u < b_constr.datalen; u++) {
22211                 int64_t b_conv_20 = b_vals[u];
22212                 void* b_conv_20_ptr = untag_ptr(b_conv_20);
22213                 CHECK_ACCESS(b_conv_20_ptr);
22214                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
22215                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)untag_ptr(b_conv_20));
22216                 b_constr.data[u] = b_conv_20_conv;
22217         }
22218         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
22219         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22220         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
22221         return tag_ptr(ret_conv, true);
22222 }
22223
22224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22225         if (!ptr_is_owned(_res)) return;
22226         void* _res_ptr = untag_ptr(_res);
22227         CHECK_ACCESS(_res_ptr);
22228         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
22229         FREE(untag_ptr(_res));
22230         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
22231 }
22232
22233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22234         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
22235         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22236         if (_res_constr.datalen > 0)
22237                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
22238         else
22239                 _res_constr.data = NULL;
22240         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22241         for (size_t n = 0; n < _res_constr.datalen; n++) {
22242                 int64_t _res_conv_39 = _res_vals[n];
22243                 void* _res_conv_39_ptr = untag_ptr(_res_conv_39);
22244                 CHECK_ACCESS(_res_conv_39_ptr);
22245                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
22246                 FREE(untag_ptr(_res_conv_39));
22247                 _res_constr.data[n] = _res_conv_39_conv;
22248         }
22249         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22250         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
22251 }
22252
22253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22254         LDKCVec_BalanceZ _res_constr;
22255         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22256         if (_res_constr.datalen > 0)
22257                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
22258         else
22259                 _res_constr.data = NULL;
22260         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22261         for (size_t j = 0; j < _res_constr.datalen; j++) {
22262                 int64_t _res_conv_9 = _res_vals[j];
22263                 void* _res_conv_9_ptr = untag_ptr(_res_conv_9);
22264                 CHECK_ACCESS(_res_conv_9_ptr);
22265                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
22266                 FREE(untag_ptr(_res_conv_9));
22267                 _res_constr.data[j] = _res_conv_9_conv;
22268         }
22269         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22270         CVec_BalanceZ_free(_res_constr);
22271 }
22272
22273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22274         void* o_ptr = untag_ptr(o);
22275         CHECK_ACCESS(o_ptr);
22276         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
22277         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o));
22278         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22279         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
22280         return tag_ptr(ret_conv, true);
22281 }
22282
22283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22284         LDKDecodeError e_conv;
22285         e_conv.inner = untag_ptr(e);
22286         e_conv.is_owned = ptr_is_owned(e);
22287         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22288         e_conv = DecodeError_clone(&e_conv);
22289         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22290         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
22291         return tag_ptr(ret_conv, true);
22292 }
22293
22294 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22295         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(o);
22296         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
22297         return ret_conv;
22298 }
22299
22300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22301         if (!ptr_is_owned(_res)) return;
22302         void* _res_ptr = untag_ptr(_res);
22303         CHECK_ACCESS(_res_ptr);
22304         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
22305         FREE(untag_ptr(_res));
22306         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
22307 }
22308
22309 static inline uint64_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
22310         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22311         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
22312         return tag_ptr(ret_conv, true);
22313 }
22314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22315         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(arg);
22316         int64_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
22317         return ret_conv;
22318 }
22319
22320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22321         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(orig);
22322         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22323         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
22324         return tag_ptr(ret_conv, true);
22325 }
22326
22327 static inline uint64_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
22328         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22329         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
22330         return tag_ptr(ret_conv, true);
22331 }
22332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22333         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(arg);
22334         int64_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
22335         return ret_conv;
22336 }
22337
22338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22339         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(orig);
22340         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22341         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
22342         return tag_ptr(ret_conv, true);
22343 }
22344
22345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
22346         LDKPublicKey a_ref;
22347         CHECK((*env)->GetArrayLength(env, a) == 33);
22348         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
22349         void* b_ptr = untag_ptr(b);
22350         CHECK_ACCESS(b_ptr);
22351         LDKType b_conv = *(LDKType*)(b_ptr);
22352         if (b_conv.free == LDKType_JCalls_free) {
22353                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22354                 LDKType_JCalls_cloned(&b_conv);
22355         }
22356         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22357         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
22358         return tag_ptr(ret_conv, true);
22359 }
22360
22361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22362         if (!ptr_is_owned(_res)) return;
22363         void* _res_ptr = untag_ptr(_res);
22364         CHECK_ACCESS(_res_ptr);
22365         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
22366         FREE(untag_ptr(_res));
22367         C2Tuple_PublicKeyTypeZ_free(_res_conv);
22368 }
22369
22370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22371         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
22372         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22373         if (_res_constr.datalen > 0)
22374                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
22375         else
22376                 _res_constr.data = NULL;
22377         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22378         for (size_t z = 0; z < _res_constr.datalen; z++) {
22379                 int64_t _res_conv_25 = _res_vals[z];
22380                 void* _res_conv_25_ptr = untag_ptr(_res_conv_25);
22381                 CHECK_ACCESS(_res_conv_25_ptr);
22382                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
22383                 FREE(untag_ptr(_res_conv_25));
22384                 _res_constr.data[z] = _res_conv_25_conv;
22385         }
22386         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22387         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
22388 }
22389
22390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22391         void* o_ptr = untag_ptr(o);
22392         CHECK_ACCESS(o_ptr);
22393         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
22394         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
22395         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
22396         *ret_copy = COption_NetAddressZ_some(o_conv);
22397         int64_t ret_ref = tag_ptr(ret_copy, true);
22398         return ret_ref;
22399 }
22400
22401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1none(JNIEnv *env, jclass clz) {
22402         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
22403         *ret_copy = COption_NetAddressZ_none();
22404         int64_t ret_ref = tag_ptr(ret_copy, true);
22405         return ret_ref;
22406 }
22407
22408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22409         if (!ptr_is_owned(_res)) return;
22410         void* _res_ptr = untag_ptr(_res);
22411         CHECK_ACCESS(_res_ptr);
22412         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
22413         FREE(untag_ptr(_res));
22414         COption_NetAddressZ_free(_res_conv);
22415 }
22416
22417 static inline uint64_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
22418         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
22419         *ret_copy = COption_NetAddressZ_clone(arg);
22420         int64_t ret_ref = tag_ptr(ret_copy, true);
22421         return ret_ref;
22422 }
22423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22424         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)untag_ptr(arg);
22425         int64_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
22426         return ret_conv;
22427 }
22428
22429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22430         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)untag_ptr(orig);
22431         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
22432         *ret_copy = COption_NetAddressZ_clone(orig_conv);
22433         int64_t ret_ref = tag_ptr(ret_copy, true);
22434         return ret_ref;
22435 }
22436
22437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22438         LDKCVec_u8Z o_ref;
22439         o_ref.datalen = (*env)->GetArrayLength(env, o);
22440         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
22441         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
22442         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22443         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
22444         return tag_ptr(ret_conv, true);
22445 }
22446
22447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22448         LDKPeerHandleError e_conv;
22449         e_conv.inner = untag_ptr(e);
22450         e_conv.is_owned = ptr_is_owned(e);
22451         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22452         e_conv = PeerHandleError_clone(&e_conv);
22453         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22454         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
22455         return tag_ptr(ret_conv, true);
22456 }
22457
22458 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22459         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(o);
22460         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
22461         return ret_conv;
22462 }
22463
22464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22465         if (!ptr_is_owned(_res)) return;
22466         void* _res_ptr = untag_ptr(_res);
22467         CHECK_ACCESS(_res_ptr);
22468         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
22469         FREE(untag_ptr(_res));
22470         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
22471 }
22472
22473 static inline uint64_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
22474         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22475         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
22476         return tag_ptr(ret_conv, true);
22477 }
22478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22479         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(arg);
22480         int64_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
22481         return ret_conv;
22482 }
22483
22484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22485         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(orig);
22486         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22487         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
22488         return tag_ptr(ret_conv, true);
22489 }
22490
22491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
22492         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22493         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
22494         return tag_ptr(ret_conv, true);
22495 }
22496
22497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22498         LDKPeerHandleError e_conv;
22499         e_conv.inner = untag_ptr(e);
22500         e_conv.is_owned = ptr_is_owned(e);
22501         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22502         e_conv = PeerHandleError_clone(&e_conv);
22503         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22504         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
22505         return tag_ptr(ret_conv, true);
22506 }
22507
22508 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22509         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(o);
22510         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
22511         return ret_conv;
22512 }
22513
22514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22515         if (!ptr_is_owned(_res)) return;
22516         void* _res_ptr = untag_ptr(_res);
22517         CHECK_ACCESS(_res_ptr);
22518         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
22519         FREE(untag_ptr(_res));
22520         CResult_NonePeerHandleErrorZ_free(_res_conv);
22521 }
22522
22523 static inline uint64_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
22524         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22525         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
22526         return tag_ptr(ret_conv, true);
22527 }
22528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22529         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(arg);
22530         int64_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
22531         return ret_conv;
22532 }
22533
22534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22535         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(orig);
22536         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
22537         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
22538         return tag_ptr(ret_conv, true);
22539 }
22540
22541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
22542         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22543         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
22544         return tag_ptr(ret_conv, true);
22545 }
22546
22547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22548         LDKPeerHandleError e_conv;
22549         e_conv.inner = untag_ptr(e);
22550         e_conv.is_owned = ptr_is_owned(e);
22551         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22552         e_conv = PeerHandleError_clone(&e_conv);
22553         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22554         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
22555         return tag_ptr(ret_conv, true);
22556 }
22557
22558 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22559         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(o);
22560         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
22561         return ret_conv;
22562 }
22563
22564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22565         if (!ptr_is_owned(_res)) return;
22566         void* _res_ptr = untag_ptr(_res);
22567         CHECK_ACCESS(_res_ptr);
22568         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
22569         FREE(untag_ptr(_res));
22570         CResult_boolPeerHandleErrorZ_free(_res_conv);
22571 }
22572
22573 static inline uint64_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
22574         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22575         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
22576         return tag_ptr(ret_conv, true);
22577 }
22578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22579         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(arg);
22580         int64_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
22581         return ret_conv;
22582 }
22583
22584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22585         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(orig);
22586         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
22587         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
22588         return tag_ptr(ret_conv, true);
22589 }
22590
22591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1ok(JNIEnv *env, jclass clz) {
22592         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
22593         *ret_conv = CResult_NoneSendErrorZ_ok();
22594         return tag_ptr(ret_conv, true);
22595 }
22596
22597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22598         void* e_ptr = untag_ptr(e);
22599         CHECK_ACCESS(e_ptr);
22600         LDKSendError e_conv = *(LDKSendError*)(e_ptr);
22601         e_conv = SendError_clone((LDKSendError*)untag_ptr(e));
22602         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
22603         *ret_conv = CResult_NoneSendErrorZ_err(e_conv);
22604         return tag_ptr(ret_conv, true);
22605 }
22606
22607 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22608         LDKCResult_NoneSendErrorZ* o_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(o);
22609         jboolean ret_conv = CResult_NoneSendErrorZ_is_ok(o_conv);
22610         return ret_conv;
22611 }
22612
22613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22614         if (!ptr_is_owned(_res)) return;
22615         void* _res_ptr = untag_ptr(_res);
22616         CHECK_ACCESS(_res_ptr);
22617         LDKCResult_NoneSendErrorZ _res_conv = *(LDKCResult_NoneSendErrorZ*)(_res_ptr);
22618         FREE(untag_ptr(_res));
22619         CResult_NoneSendErrorZ_free(_res_conv);
22620 }
22621
22622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1ok(JNIEnv *env, jclass clz, int32_t o) {
22623         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
22624         *ret_conv = CResult_u32GraphSyncErrorZ_ok(o);
22625         return tag_ptr(ret_conv, true);
22626 }
22627
22628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22629         void* e_ptr = untag_ptr(e);
22630         CHECK_ACCESS(e_ptr);
22631         LDKGraphSyncError e_conv = *(LDKGraphSyncError*)(e_ptr);
22632         e_conv = GraphSyncError_clone((LDKGraphSyncError*)untag_ptr(e));
22633         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
22634         *ret_conv = CResult_u32GraphSyncErrorZ_err(e_conv);
22635         return tag_ptr(ret_conv, true);
22636 }
22637
22638 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22639         LDKCResult_u32GraphSyncErrorZ* o_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(o);
22640         jboolean ret_conv = CResult_u32GraphSyncErrorZ_is_ok(o_conv);
22641         return ret_conv;
22642 }
22643
22644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22645         if (!ptr_is_owned(_res)) return;
22646         void* _res_ptr = untag_ptr(_res);
22647         CHECK_ACCESS(_res_ptr);
22648         LDKCResult_u32GraphSyncErrorZ _res_conv = *(LDKCResult_u32GraphSyncErrorZ*)(_res_ptr);
22649         FREE(untag_ptr(_res));
22650         CResult_u32GraphSyncErrorZ_free(_res_conv);
22651 }
22652
22653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22654         void* o_ptr = untag_ptr(o);
22655         CHECK_ACCESS(o_ptr);
22656         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
22657         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
22658         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
22659         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
22660         return tag_ptr(ret_conv, true);
22661 }
22662
22663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22664         LDKDecodeError e_conv;
22665         e_conv.inner = untag_ptr(e);
22666         e_conv.is_owned = ptr_is_owned(e);
22667         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22668         e_conv = DecodeError_clone(&e_conv);
22669         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
22670         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
22671         return tag_ptr(ret_conv, true);
22672 }
22673
22674 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22675         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(o);
22676         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
22677         return ret_conv;
22678 }
22679
22680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22681         if (!ptr_is_owned(_res)) return;
22682         void* _res_ptr = untag_ptr(_res);
22683         CHECK_ACCESS(_res_ptr);
22684         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
22685         FREE(untag_ptr(_res));
22686         CResult_NetAddressDecodeErrorZ_free(_res_conv);
22687 }
22688
22689 static inline uint64_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
22690         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
22691         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
22692         return tag_ptr(ret_conv, true);
22693 }
22694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22695         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(arg);
22696         int64_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
22697         return ret_conv;
22698 }
22699
22700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22701         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(orig);
22702         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
22703         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
22704         return tag_ptr(ret_conv, true);
22705 }
22706
22707 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22708         LDKCVec_UpdateAddHTLCZ _res_constr;
22709         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22710         if (_res_constr.datalen > 0)
22711                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
22712         else
22713                 _res_constr.data = NULL;
22714         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22715         for (size_t p = 0; p < _res_constr.datalen; p++) {
22716                 int64_t _res_conv_15 = _res_vals[p];
22717                 LDKUpdateAddHTLC _res_conv_15_conv;
22718                 _res_conv_15_conv.inner = untag_ptr(_res_conv_15);
22719                 _res_conv_15_conv.is_owned = ptr_is_owned(_res_conv_15);
22720                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
22721                 _res_constr.data[p] = _res_conv_15_conv;
22722         }
22723         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22724         CVec_UpdateAddHTLCZ_free(_res_constr);
22725 }
22726
22727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22728         LDKCVec_UpdateFulfillHTLCZ _res_constr;
22729         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22730         if (_res_constr.datalen > 0)
22731                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
22732         else
22733                 _res_constr.data = NULL;
22734         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22735         for (size_t t = 0; t < _res_constr.datalen; t++) {
22736                 int64_t _res_conv_19 = _res_vals[t];
22737                 LDKUpdateFulfillHTLC _res_conv_19_conv;
22738                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
22739                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
22740                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
22741                 _res_constr.data[t] = _res_conv_19_conv;
22742         }
22743         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22744         CVec_UpdateFulfillHTLCZ_free(_res_constr);
22745 }
22746
22747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22748         LDKCVec_UpdateFailHTLCZ _res_constr;
22749         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22750         if (_res_constr.datalen > 0)
22751                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
22752         else
22753                 _res_constr.data = NULL;
22754         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22755         for (size_t q = 0; q < _res_constr.datalen; q++) {
22756                 int64_t _res_conv_16 = _res_vals[q];
22757                 LDKUpdateFailHTLC _res_conv_16_conv;
22758                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
22759                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
22760                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
22761                 _res_constr.data[q] = _res_conv_16_conv;
22762         }
22763         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22764         CVec_UpdateFailHTLCZ_free(_res_constr);
22765 }
22766
22767 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22768         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
22769         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22770         if (_res_constr.datalen > 0)
22771                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
22772         else
22773                 _res_constr.data = NULL;
22774         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22775         for (size_t z = 0; z < _res_constr.datalen; z++) {
22776                 int64_t _res_conv_25 = _res_vals[z];
22777                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
22778                 _res_conv_25_conv.inner = untag_ptr(_res_conv_25);
22779                 _res_conv_25_conv.is_owned = ptr_is_owned(_res_conv_25);
22780                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
22781                 _res_constr.data[z] = _res_conv_25_conv;
22782         }
22783         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22784         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
22785 }
22786
22787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22788         LDKAcceptChannel o_conv;
22789         o_conv.inner = untag_ptr(o);
22790         o_conv.is_owned = ptr_is_owned(o);
22791         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22792         o_conv = AcceptChannel_clone(&o_conv);
22793         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
22794         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
22795         return tag_ptr(ret_conv, true);
22796 }
22797
22798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22799         LDKDecodeError e_conv;
22800         e_conv.inner = untag_ptr(e);
22801         e_conv.is_owned = ptr_is_owned(e);
22802         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22803         e_conv = DecodeError_clone(&e_conv);
22804         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
22805         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
22806         return tag_ptr(ret_conv, true);
22807 }
22808
22809 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22810         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(o);
22811         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
22812         return ret_conv;
22813 }
22814
22815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22816         if (!ptr_is_owned(_res)) return;
22817         void* _res_ptr = untag_ptr(_res);
22818         CHECK_ACCESS(_res_ptr);
22819         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
22820         FREE(untag_ptr(_res));
22821         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
22822 }
22823
22824 static inline uint64_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
22825         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
22826         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
22827         return tag_ptr(ret_conv, true);
22828 }
22829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22830         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(arg);
22831         int64_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
22832         return ret_conv;
22833 }
22834
22835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22836         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(orig);
22837         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
22838         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
22839         return tag_ptr(ret_conv, true);
22840 }
22841
22842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22843         LDKAnnouncementSignatures o_conv;
22844         o_conv.inner = untag_ptr(o);
22845         o_conv.is_owned = ptr_is_owned(o);
22846         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22847         o_conv = AnnouncementSignatures_clone(&o_conv);
22848         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
22849         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
22850         return tag_ptr(ret_conv, true);
22851 }
22852
22853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22854         LDKDecodeError e_conv;
22855         e_conv.inner = untag_ptr(e);
22856         e_conv.is_owned = ptr_is_owned(e);
22857         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22858         e_conv = DecodeError_clone(&e_conv);
22859         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
22860         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
22861         return tag_ptr(ret_conv, true);
22862 }
22863
22864 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22865         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(o);
22866         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
22867         return ret_conv;
22868 }
22869
22870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22871         if (!ptr_is_owned(_res)) return;
22872         void* _res_ptr = untag_ptr(_res);
22873         CHECK_ACCESS(_res_ptr);
22874         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
22875         FREE(untag_ptr(_res));
22876         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
22877 }
22878
22879 static inline uint64_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
22880         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
22881         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
22882         return tag_ptr(ret_conv, true);
22883 }
22884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22885         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(arg);
22886         int64_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
22887         return ret_conv;
22888 }
22889
22890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22891         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(orig);
22892         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
22893         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
22894         return tag_ptr(ret_conv, true);
22895 }
22896
22897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22898         LDKChannelReestablish o_conv;
22899         o_conv.inner = untag_ptr(o);
22900         o_conv.is_owned = ptr_is_owned(o);
22901         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22902         o_conv = ChannelReestablish_clone(&o_conv);
22903         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22904         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
22905         return tag_ptr(ret_conv, true);
22906 }
22907
22908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22909         LDKDecodeError e_conv;
22910         e_conv.inner = untag_ptr(e);
22911         e_conv.is_owned = ptr_is_owned(e);
22912         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22913         e_conv = DecodeError_clone(&e_conv);
22914         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22915         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
22916         return tag_ptr(ret_conv, true);
22917 }
22918
22919 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22920         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(o);
22921         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
22922         return ret_conv;
22923 }
22924
22925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22926         if (!ptr_is_owned(_res)) return;
22927         void* _res_ptr = untag_ptr(_res);
22928         CHECK_ACCESS(_res_ptr);
22929         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
22930         FREE(untag_ptr(_res));
22931         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
22932 }
22933
22934 static inline uint64_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
22935         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22936         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
22937         return tag_ptr(ret_conv, true);
22938 }
22939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22940         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(arg);
22941         int64_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
22942         return ret_conv;
22943 }
22944
22945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22946         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(orig);
22947         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
22948         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
22949         return tag_ptr(ret_conv, true);
22950 }
22951
22952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22953         LDKClosingSigned o_conv;
22954         o_conv.inner = untag_ptr(o);
22955         o_conv.is_owned = ptr_is_owned(o);
22956         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22957         o_conv = ClosingSigned_clone(&o_conv);
22958         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22959         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
22960         return tag_ptr(ret_conv, true);
22961 }
22962
22963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22964         LDKDecodeError e_conv;
22965         e_conv.inner = untag_ptr(e);
22966         e_conv.is_owned = ptr_is_owned(e);
22967         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22968         e_conv = DecodeError_clone(&e_conv);
22969         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22970         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
22971         return tag_ptr(ret_conv, true);
22972 }
22973
22974 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22975         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(o);
22976         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
22977         return ret_conv;
22978 }
22979
22980 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22981         if (!ptr_is_owned(_res)) return;
22982         void* _res_ptr = untag_ptr(_res);
22983         CHECK_ACCESS(_res_ptr);
22984         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
22985         FREE(untag_ptr(_res));
22986         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
22987 }
22988
22989 static inline uint64_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
22990         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
22991         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
22992         return tag_ptr(ret_conv, true);
22993 }
22994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22995         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(arg);
22996         int64_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
22997         return ret_conv;
22998 }
22999
23000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23001         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(orig);
23002         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
23003         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
23004         return tag_ptr(ret_conv, true);
23005 }
23006
23007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23008         LDKClosingSignedFeeRange o_conv;
23009         o_conv.inner = untag_ptr(o);
23010         o_conv.is_owned = ptr_is_owned(o);
23011         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23012         o_conv = ClosingSignedFeeRange_clone(&o_conv);
23013         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
23014         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
23015         return tag_ptr(ret_conv, true);
23016 }
23017
23018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23019         LDKDecodeError e_conv;
23020         e_conv.inner = untag_ptr(e);
23021         e_conv.is_owned = ptr_is_owned(e);
23022         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23023         e_conv = DecodeError_clone(&e_conv);
23024         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
23025         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
23026         return tag_ptr(ret_conv, true);
23027 }
23028
23029 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23030         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(o);
23031         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
23032         return ret_conv;
23033 }
23034
23035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23036         if (!ptr_is_owned(_res)) return;
23037         void* _res_ptr = untag_ptr(_res);
23038         CHECK_ACCESS(_res_ptr);
23039         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
23040         FREE(untag_ptr(_res));
23041         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
23042 }
23043
23044 static inline uint64_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
23045         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
23046         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
23047         return tag_ptr(ret_conv, true);
23048 }
23049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23050         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(arg);
23051         int64_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
23052         return ret_conv;
23053 }
23054
23055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23056         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(orig);
23057         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
23058         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
23059         return tag_ptr(ret_conv, true);
23060 }
23061
23062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23063         LDKCommitmentSigned o_conv;
23064         o_conv.inner = untag_ptr(o);
23065         o_conv.is_owned = ptr_is_owned(o);
23066         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23067         o_conv = CommitmentSigned_clone(&o_conv);
23068         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
23069         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
23070         return tag_ptr(ret_conv, true);
23071 }
23072
23073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23074         LDKDecodeError e_conv;
23075         e_conv.inner = untag_ptr(e);
23076         e_conv.is_owned = ptr_is_owned(e);
23077         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23078         e_conv = DecodeError_clone(&e_conv);
23079         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
23080         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
23081         return tag_ptr(ret_conv, true);
23082 }
23083
23084 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23085         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(o);
23086         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
23087         return ret_conv;
23088 }
23089
23090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23091         if (!ptr_is_owned(_res)) return;
23092         void* _res_ptr = untag_ptr(_res);
23093         CHECK_ACCESS(_res_ptr);
23094         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
23095         FREE(untag_ptr(_res));
23096         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
23097 }
23098
23099 static inline uint64_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
23100         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
23101         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
23102         return tag_ptr(ret_conv, true);
23103 }
23104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23105         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(arg);
23106         int64_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
23107         return ret_conv;
23108 }
23109
23110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23111         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(orig);
23112         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
23113         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
23114         return tag_ptr(ret_conv, true);
23115 }
23116
23117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23118         LDKFundingCreated o_conv;
23119         o_conv.inner = untag_ptr(o);
23120         o_conv.is_owned = ptr_is_owned(o);
23121         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23122         o_conv = FundingCreated_clone(&o_conv);
23123         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
23124         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
23125         return tag_ptr(ret_conv, true);
23126 }
23127
23128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23129         LDKDecodeError e_conv;
23130         e_conv.inner = untag_ptr(e);
23131         e_conv.is_owned = ptr_is_owned(e);
23132         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23133         e_conv = DecodeError_clone(&e_conv);
23134         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
23135         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
23136         return tag_ptr(ret_conv, true);
23137 }
23138
23139 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23140         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(o);
23141         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
23142         return ret_conv;
23143 }
23144
23145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23146         if (!ptr_is_owned(_res)) return;
23147         void* _res_ptr = untag_ptr(_res);
23148         CHECK_ACCESS(_res_ptr);
23149         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
23150         FREE(untag_ptr(_res));
23151         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
23152 }
23153
23154 static inline uint64_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
23155         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
23156         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
23157         return tag_ptr(ret_conv, true);
23158 }
23159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23160         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(arg);
23161         int64_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
23162         return ret_conv;
23163 }
23164
23165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23166         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(orig);
23167         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
23168         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
23169         return tag_ptr(ret_conv, true);
23170 }
23171
23172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23173         LDKFundingSigned o_conv;
23174         o_conv.inner = untag_ptr(o);
23175         o_conv.is_owned = ptr_is_owned(o);
23176         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23177         o_conv = FundingSigned_clone(&o_conv);
23178         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
23179         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
23180         return tag_ptr(ret_conv, true);
23181 }
23182
23183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23184         LDKDecodeError e_conv;
23185         e_conv.inner = untag_ptr(e);
23186         e_conv.is_owned = ptr_is_owned(e);
23187         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23188         e_conv = DecodeError_clone(&e_conv);
23189         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
23190         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
23191         return tag_ptr(ret_conv, true);
23192 }
23193
23194 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23195         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(o);
23196         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
23197         return ret_conv;
23198 }
23199
23200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23201         if (!ptr_is_owned(_res)) return;
23202         void* _res_ptr = untag_ptr(_res);
23203         CHECK_ACCESS(_res_ptr);
23204         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
23205         FREE(untag_ptr(_res));
23206         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
23207 }
23208
23209 static inline uint64_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
23210         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
23211         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
23212         return tag_ptr(ret_conv, true);
23213 }
23214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23215         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(arg);
23216         int64_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
23217         return ret_conv;
23218 }
23219
23220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23221         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(orig);
23222         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
23223         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
23224         return tag_ptr(ret_conv, true);
23225 }
23226
23227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23228         LDKChannelReady o_conv;
23229         o_conv.inner = untag_ptr(o);
23230         o_conv.is_owned = ptr_is_owned(o);
23231         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23232         o_conv = ChannelReady_clone(&o_conv);
23233         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
23234         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
23235         return tag_ptr(ret_conv, true);
23236 }
23237
23238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23239         LDKDecodeError e_conv;
23240         e_conv.inner = untag_ptr(e);
23241         e_conv.is_owned = ptr_is_owned(e);
23242         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23243         e_conv = DecodeError_clone(&e_conv);
23244         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
23245         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
23246         return tag_ptr(ret_conv, true);
23247 }
23248
23249 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23250         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(o);
23251         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
23252         return ret_conv;
23253 }
23254
23255 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23256         if (!ptr_is_owned(_res)) return;
23257         void* _res_ptr = untag_ptr(_res);
23258         CHECK_ACCESS(_res_ptr);
23259         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
23260         FREE(untag_ptr(_res));
23261         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
23262 }
23263
23264 static inline uint64_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
23265         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
23266         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
23267         return tag_ptr(ret_conv, true);
23268 }
23269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23270         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(arg);
23271         int64_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
23272         return ret_conv;
23273 }
23274
23275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23276         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(orig);
23277         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
23278         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
23279         return tag_ptr(ret_conv, true);
23280 }
23281
23282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23283         LDKInit o_conv;
23284         o_conv.inner = untag_ptr(o);
23285         o_conv.is_owned = ptr_is_owned(o);
23286         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23287         o_conv = Init_clone(&o_conv);
23288         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
23289         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
23290         return tag_ptr(ret_conv, true);
23291 }
23292
23293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23294         LDKDecodeError e_conv;
23295         e_conv.inner = untag_ptr(e);
23296         e_conv.is_owned = ptr_is_owned(e);
23297         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23298         e_conv = DecodeError_clone(&e_conv);
23299         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
23300         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
23301         return tag_ptr(ret_conv, true);
23302 }
23303
23304 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23305         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(o);
23306         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
23307         return ret_conv;
23308 }
23309
23310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23311         if (!ptr_is_owned(_res)) return;
23312         void* _res_ptr = untag_ptr(_res);
23313         CHECK_ACCESS(_res_ptr);
23314         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
23315         FREE(untag_ptr(_res));
23316         CResult_InitDecodeErrorZ_free(_res_conv);
23317 }
23318
23319 static inline uint64_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
23320         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
23321         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
23322         return tag_ptr(ret_conv, true);
23323 }
23324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23325         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(arg);
23326         int64_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
23327         return ret_conv;
23328 }
23329
23330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23331         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(orig);
23332         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
23333         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
23334         return tag_ptr(ret_conv, true);
23335 }
23336
23337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23338         LDKOpenChannel o_conv;
23339         o_conv.inner = untag_ptr(o);
23340         o_conv.is_owned = ptr_is_owned(o);
23341         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23342         o_conv = OpenChannel_clone(&o_conv);
23343         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
23344         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
23345         return tag_ptr(ret_conv, true);
23346 }
23347
23348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23349         LDKDecodeError e_conv;
23350         e_conv.inner = untag_ptr(e);
23351         e_conv.is_owned = ptr_is_owned(e);
23352         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23353         e_conv = DecodeError_clone(&e_conv);
23354         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
23355         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
23356         return tag_ptr(ret_conv, true);
23357 }
23358
23359 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23360         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(o);
23361         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
23362         return ret_conv;
23363 }
23364
23365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23366         if (!ptr_is_owned(_res)) return;
23367         void* _res_ptr = untag_ptr(_res);
23368         CHECK_ACCESS(_res_ptr);
23369         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
23370         FREE(untag_ptr(_res));
23371         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
23372 }
23373
23374 static inline uint64_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
23375         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
23376         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
23377         return tag_ptr(ret_conv, true);
23378 }
23379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23380         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(arg);
23381         int64_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
23382         return ret_conv;
23383 }
23384
23385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23386         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(orig);
23387         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
23388         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
23389         return tag_ptr(ret_conv, true);
23390 }
23391
23392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23393         LDKRevokeAndACK o_conv;
23394         o_conv.inner = untag_ptr(o);
23395         o_conv.is_owned = ptr_is_owned(o);
23396         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23397         o_conv = RevokeAndACK_clone(&o_conv);
23398         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
23399         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
23400         return tag_ptr(ret_conv, true);
23401 }
23402
23403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23404         LDKDecodeError e_conv;
23405         e_conv.inner = untag_ptr(e);
23406         e_conv.is_owned = ptr_is_owned(e);
23407         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23408         e_conv = DecodeError_clone(&e_conv);
23409         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
23410         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
23411         return tag_ptr(ret_conv, true);
23412 }
23413
23414 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23415         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(o);
23416         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
23417         return ret_conv;
23418 }
23419
23420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23421         if (!ptr_is_owned(_res)) return;
23422         void* _res_ptr = untag_ptr(_res);
23423         CHECK_ACCESS(_res_ptr);
23424         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
23425         FREE(untag_ptr(_res));
23426         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
23427 }
23428
23429 static inline uint64_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
23430         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
23431         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
23432         return tag_ptr(ret_conv, true);
23433 }
23434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23435         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(arg);
23436         int64_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
23437         return ret_conv;
23438 }
23439
23440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23441         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(orig);
23442         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
23443         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
23444         return tag_ptr(ret_conv, true);
23445 }
23446
23447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23448         LDKShutdown o_conv;
23449         o_conv.inner = untag_ptr(o);
23450         o_conv.is_owned = ptr_is_owned(o);
23451         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23452         o_conv = Shutdown_clone(&o_conv);
23453         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
23454         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
23455         return tag_ptr(ret_conv, true);
23456 }
23457
23458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23459         LDKDecodeError e_conv;
23460         e_conv.inner = untag_ptr(e);
23461         e_conv.is_owned = ptr_is_owned(e);
23462         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23463         e_conv = DecodeError_clone(&e_conv);
23464         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
23465         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
23466         return tag_ptr(ret_conv, true);
23467 }
23468
23469 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23470         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(o);
23471         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
23472         return ret_conv;
23473 }
23474
23475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23476         if (!ptr_is_owned(_res)) return;
23477         void* _res_ptr = untag_ptr(_res);
23478         CHECK_ACCESS(_res_ptr);
23479         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
23480         FREE(untag_ptr(_res));
23481         CResult_ShutdownDecodeErrorZ_free(_res_conv);
23482 }
23483
23484 static inline uint64_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
23485         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
23486         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
23487         return tag_ptr(ret_conv, true);
23488 }
23489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23490         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(arg);
23491         int64_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
23492         return ret_conv;
23493 }
23494
23495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23496         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(orig);
23497         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
23498         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
23499         return tag_ptr(ret_conv, true);
23500 }
23501
23502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23503         LDKUpdateFailHTLC o_conv;
23504         o_conv.inner = untag_ptr(o);
23505         o_conv.is_owned = ptr_is_owned(o);
23506         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23507         o_conv = UpdateFailHTLC_clone(&o_conv);
23508         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23509         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
23510         return tag_ptr(ret_conv, true);
23511 }
23512
23513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23514         LDKDecodeError e_conv;
23515         e_conv.inner = untag_ptr(e);
23516         e_conv.is_owned = ptr_is_owned(e);
23517         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23518         e_conv = DecodeError_clone(&e_conv);
23519         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23520         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
23521         return tag_ptr(ret_conv, true);
23522 }
23523
23524 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23525         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(o);
23526         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
23527         return ret_conv;
23528 }
23529
23530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23531         if (!ptr_is_owned(_res)) return;
23532         void* _res_ptr = untag_ptr(_res);
23533         CHECK_ACCESS(_res_ptr);
23534         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
23535         FREE(untag_ptr(_res));
23536         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
23537 }
23538
23539 static inline uint64_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
23540         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23541         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
23542         return tag_ptr(ret_conv, true);
23543 }
23544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23545         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(arg);
23546         int64_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
23547         return ret_conv;
23548 }
23549
23550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23551         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(orig);
23552         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
23553         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
23554         return tag_ptr(ret_conv, true);
23555 }
23556
23557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23558         LDKUpdateFailMalformedHTLC o_conv;
23559         o_conv.inner = untag_ptr(o);
23560         o_conv.is_owned = ptr_is_owned(o);
23561         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23562         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
23563         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23564         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
23565         return tag_ptr(ret_conv, true);
23566 }
23567
23568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23569         LDKDecodeError e_conv;
23570         e_conv.inner = untag_ptr(e);
23571         e_conv.is_owned = ptr_is_owned(e);
23572         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23573         e_conv = DecodeError_clone(&e_conv);
23574         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23575         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
23576         return tag_ptr(ret_conv, true);
23577 }
23578
23579 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23580         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(o);
23581         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
23582         return ret_conv;
23583 }
23584
23585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23586         if (!ptr_is_owned(_res)) return;
23587         void* _res_ptr = untag_ptr(_res);
23588         CHECK_ACCESS(_res_ptr);
23589         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
23590         FREE(untag_ptr(_res));
23591         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
23592 }
23593
23594 static inline uint64_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
23595         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23596         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
23597         return tag_ptr(ret_conv, true);
23598 }
23599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23600         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(arg);
23601         int64_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
23602         return ret_conv;
23603 }
23604
23605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23606         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(orig);
23607         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
23608         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
23609         return tag_ptr(ret_conv, true);
23610 }
23611
23612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23613         LDKUpdateFee o_conv;
23614         o_conv.inner = untag_ptr(o);
23615         o_conv.is_owned = ptr_is_owned(o);
23616         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23617         o_conv = UpdateFee_clone(&o_conv);
23618         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23619         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
23620         return tag_ptr(ret_conv, true);
23621 }
23622
23623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23624         LDKDecodeError e_conv;
23625         e_conv.inner = untag_ptr(e);
23626         e_conv.is_owned = ptr_is_owned(e);
23627         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23628         e_conv = DecodeError_clone(&e_conv);
23629         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23630         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
23631         return tag_ptr(ret_conv, true);
23632 }
23633
23634 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23635         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(o);
23636         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
23637         return ret_conv;
23638 }
23639
23640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23641         if (!ptr_is_owned(_res)) return;
23642         void* _res_ptr = untag_ptr(_res);
23643         CHECK_ACCESS(_res_ptr);
23644         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
23645         FREE(untag_ptr(_res));
23646         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
23647 }
23648
23649 static inline uint64_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
23650         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23651         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
23652         return tag_ptr(ret_conv, true);
23653 }
23654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23655         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(arg);
23656         int64_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
23657         return ret_conv;
23658 }
23659
23660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23661         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(orig);
23662         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
23663         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
23664         return tag_ptr(ret_conv, true);
23665 }
23666
23667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23668         LDKUpdateFulfillHTLC o_conv;
23669         o_conv.inner = untag_ptr(o);
23670         o_conv.is_owned = ptr_is_owned(o);
23671         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23672         o_conv = UpdateFulfillHTLC_clone(&o_conv);
23673         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
23674         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
23675         return tag_ptr(ret_conv, true);
23676 }
23677
23678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23679         LDKDecodeError e_conv;
23680         e_conv.inner = untag_ptr(e);
23681         e_conv.is_owned = ptr_is_owned(e);
23682         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23683         e_conv = DecodeError_clone(&e_conv);
23684         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
23685         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
23686         return tag_ptr(ret_conv, true);
23687 }
23688
23689 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23690         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(o);
23691         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
23692         return ret_conv;
23693 }
23694
23695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23696         if (!ptr_is_owned(_res)) return;
23697         void* _res_ptr = untag_ptr(_res);
23698         CHECK_ACCESS(_res_ptr);
23699         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
23700         FREE(untag_ptr(_res));
23701         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
23702 }
23703
23704 static inline uint64_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
23705         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
23706         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
23707         return tag_ptr(ret_conv, true);
23708 }
23709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23710         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(arg);
23711         int64_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
23712         return ret_conv;
23713 }
23714
23715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23716         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(orig);
23717         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
23718         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
23719         return tag_ptr(ret_conv, true);
23720 }
23721
23722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23723         LDKUpdateAddHTLC o_conv;
23724         o_conv.inner = untag_ptr(o);
23725         o_conv.is_owned = ptr_is_owned(o);
23726         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23727         o_conv = UpdateAddHTLC_clone(&o_conv);
23728         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
23729         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
23730         return tag_ptr(ret_conv, true);
23731 }
23732
23733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23734         LDKDecodeError e_conv;
23735         e_conv.inner = untag_ptr(e);
23736         e_conv.is_owned = ptr_is_owned(e);
23737         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23738         e_conv = DecodeError_clone(&e_conv);
23739         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
23740         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
23741         return tag_ptr(ret_conv, true);
23742 }
23743
23744 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23745         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(o);
23746         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
23747         return ret_conv;
23748 }
23749
23750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23751         if (!ptr_is_owned(_res)) return;
23752         void* _res_ptr = untag_ptr(_res);
23753         CHECK_ACCESS(_res_ptr);
23754         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
23755         FREE(untag_ptr(_res));
23756         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
23757 }
23758
23759 static inline uint64_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
23760         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
23761         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
23762         return tag_ptr(ret_conv, true);
23763 }
23764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23765         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(arg);
23766         int64_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
23767         return ret_conv;
23768 }
23769
23770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23771         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(orig);
23772         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
23773         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
23774         return tag_ptr(ret_conv, true);
23775 }
23776
23777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23778         LDKOnionMessage o_conv;
23779         o_conv.inner = untag_ptr(o);
23780         o_conv.is_owned = ptr_is_owned(o);
23781         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23782         o_conv = OnionMessage_clone(&o_conv);
23783         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
23784         *ret_conv = CResult_OnionMessageDecodeErrorZ_ok(o_conv);
23785         return tag_ptr(ret_conv, true);
23786 }
23787
23788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23789         LDKDecodeError e_conv;
23790         e_conv.inner = untag_ptr(e);
23791         e_conv.is_owned = ptr_is_owned(e);
23792         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23793         e_conv = DecodeError_clone(&e_conv);
23794         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
23795         *ret_conv = CResult_OnionMessageDecodeErrorZ_err(e_conv);
23796         return tag_ptr(ret_conv, true);
23797 }
23798
23799 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23800         LDKCResult_OnionMessageDecodeErrorZ* o_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(o);
23801         jboolean ret_conv = CResult_OnionMessageDecodeErrorZ_is_ok(o_conv);
23802         return ret_conv;
23803 }
23804
23805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23806         if (!ptr_is_owned(_res)) return;
23807         void* _res_ptr = untag_ptr(_res);
23808         CHECK_ACCESS(_res_ptr);
23809         LDKCResult_OnionMessageDecodeErrorZ _res_conv = *(LDKCResult_OnionMessageDecodeErrorZ*)(_res_ptr);
23810         FREE(untag_ptr(_res));
23811         CResult_OnionMessageDecodeErrorZ_free(_res_conv);
23812 }
23813
23814 static inline uint64_t CResult_OnionMessageDecodeErrorZ_clone_ptr(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR arg) {
23815         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
23816         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(arg);
23817         return tag_ptr(ret_conv, true);
23818 }
23819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23820         LDKCResult_OnionMessageDecodeErrorZ* arg_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(arg);
23821         int64_t ret_conv = CResult_OnionMessageDecodeErrorZ_clone_ptr(arg_conv);
23822         return ret_conv;
23823 }
23824
23825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23826         LDKCResult_OnionMessageDecodeErrorZ* orig_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(orig);
23827         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
23828         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(orig_conv);
23829         return tag_ptr(ret_conv, true);
23830 }
23831
23832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23833         LDKPing o_conv;
23834         o_conv.inner = untag_ptr(o);
23835         o_conv.is_owned = ptr_is_owned(o);
23836         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23837         o_conv = Ping_clone(&o_conv);
23838         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
23839         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
23840         return tag_ptr(ret_conv, true);
23841 }
23842
23843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23844         LDKDecodeError e_conv;
23845         e_conv.inner = untag_ptr(e);
23846         e_conv.is_owned = ptr_is_owned(e);
23847         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23848         e_conv = DecodeError_clone(&e_conv);
23849         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
23850         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
23851         return tag_ptr(ret_conv, true);
23852 }
23853
23854 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23855         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(o);
23856         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
23857         return ret_conv;
23858 }
23859
23860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23861         if (!ptr_is_owned(_res)) return;
23862         void* _res_ptr = untag_ptr(_res);
23863         CHECK_ACCESS(_res_ptr);
23864         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
23865         FREE(untag_ptr(_res));
23866         CResult_PingDecodeErrorZ_free(_res_conv);
23867 }
23868
23869 static inline uint64_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
23870         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
23871         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
23872         return tag_ptr(ret_conv, true);
23873 }
23874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23875         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(arg);
23876         int64_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
23877         return ret_conv;
23878 }
23879
23880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23881         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(orig);
23882         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
23883         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
23884         return tag_ptr(ret_conv, true);
23885 }
23886
23887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23888         LDKPong o_conv;
23889         o_conv.inner = untag_ptr(o);
23890         o_conv.is_owned = ptr_is_owned(o);
23891         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23892         o_conv = Pong_clone(&o_conv);
23893         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
23894         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
23895         return tag_ptr(ret_conv, true);
23896 }
23897
23898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23899         LDKDecodeError e_conv;
23900         e_conv.inner = untag_ptr(e);
23901         e_conv.is_owned = ptr_is_owned(e);
23902         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23903         e_conv = DecodeError_clone(&e_conv);
23904         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
23905         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
23906         return tag_ptr(ret_conv, true);
23907 }
23908
23909 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23910         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(o);
23911         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
23912         return ret_conv;
23913 }
23914
23915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23916         if (!ptr_is_owned(_res)) return;
23917         void* _res_ptr = untag_ptr(_res);
23918         CHECK_ACCESS(_res_ptr);
23919         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
23920         FREE(untag_ptr(_res));
23921         CResult_PongDecodeErrorZ_free(_res_conv);
23922 }
23923
23924 static inline uint64_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
23925         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
23926         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
23927         return tag_ptr(ret_conv, true);
23928 }
23929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23930         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(arg);
23931         int64_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
23932         return ret_conv;
23933 }
23934
23935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23936         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(orig);
23937         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
23938         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
23939         return tag_ptr(ret_conv, true);
23940 }
23941
23942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23943         LDKUnsignedChannelAnnouncement o_conv;
23944         o_conv.inner = untag_ptr(o);
23945         o_conv.is_owned = ptr_is_owned(o);
23946         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23947         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
23948         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
23949         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
23950         return tag_ptr(ret_conv, true);
23951 }
23952
23953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23954         LDKDecodeError e_conv;
23955         e_conv.inner = untag_ptr(e);
23956         e_conv.is_owned = ptr_is_owned(e);
23957         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23958         e_conv = DecodeError_clone(&e_conv);
23959         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
23960         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
23961         return tag_ptr(ret_conv, true);
23962 }
23963
23964 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23965         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
23966         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
23967         return ret_conv;
23968 }
23969
23970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23971         if (!ptr_is_owned(_res)) return;
23972         void* _res_ptr = untag_ptr(_res);
23973         CHECK_ACCESS(_res_ptr);
23974         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
23975         FREE(untag_ptr(_res));
23976         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
23977 }
23978
23979 static inline uint64_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
23980         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
23981         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
23982         return tag_ptr(ret_conv, true);
23983 }
23984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23985         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
23986         int64_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
23987         return ret_conv;
23988 }
23989
23990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23991         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
23992         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
23993         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
23994         return tag_ptr(ret_conv, true);
23995 }
23996
23997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23998         LDKChannelAnnouncement o_conv;
23999         o_conv.inner = untag_ptr(o);
24000         o_conv.is_owned = ptr_is_owned(o);
24001         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24002         o_conv = ChannelAnnouncement_clone(&o_conv);
24003         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
24004         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
24005         return tag_ptr(ret_conv, true);
24006 }
24007
24008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24009         LDKDecodeError e_conv;
24010         e_conv.inner = untag_ptr(e);
24011         e_conv.is_owned = ptr_is_owned(e);
24012         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
24013         e_conv = DecodeError_clone(&e_conv);
24014         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
24015         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
24016         return tag_ptr(ret_conv, true);
24017 }
24018
24019 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24020         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
24021         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
24022         return ret_conv;
24023 }
24024
24025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24026         if (!ptr_is_owned(_res)) return;
24027         void* _res_ptr = untag_ptr(_res);
24028         CHECK_ACCESS(_res_ptr);
24029         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
24030         FREE(untag_ptr(_res));
24031         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
24032 }
24033
24034 static inline uint64_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
24035         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
24036         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
24037         return tag_ptr(ret_conv, true);
24038 }
24039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24040         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
24041         int64_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
24042         return ret_conv;
24043 }
24044
24045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24046         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
24047         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
24048         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
24049         return tag_ptr(ret_conv, true);
24050 }
24051
24052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24053         LDKUnsignedChannelUpdate o_conv;
24054         o_conv.inner = untag_ptr(o);
24055         o_conv.is_owned = ptr_is_owned(o);
24056         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24057         o_conv = UnsignedChannelUpdate_clone(&o_conv);
24058         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
24059         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
24060         return tag_ptr(ret_conv, true);
24061 }
24062
24063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24064         LDKDecodeError e_conv;
24065         e_conv.inner = untag_ptr(e);
24066         e_conv.is_owned = ptr_is_owned(e);
24067         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
24068         e_conv = DecodeError_clone(&e_conv);
24069         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
24070         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
24071         return tag_ptr(ret_conv, true);
24072 }
24073
24074 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24075         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(o);
24076         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
24077         return ret_conv;
24078 }
24079
24080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24081         if (!ptr_is_owned(_res)) return;
24082         void* _res_ptr = untag_ptr(_res);
24083         CHECK_ACCESS(_res_ptr);
24084         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
24085         FREE(untag_ptr(_res));
24086         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
24087 }
24088
24089 static inline uint64_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
24090         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
24091         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
24092         return tag_ptr(ret_conv, true);
24093 }
24094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24095         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(arg);
24096         int64_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
24097         return ret_conv;
24098 }
24099
24100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24101         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(orig);
24102         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
24103         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
24104         return tag_ptr(ret_conv, true);
24105 }
24106
24107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24108         LDKChannelUpdate o_conv;
24109         o_conv.inner = untag_ptr(o);
24110         o_conv.is_owned = ptr_is_owned(o);
24111         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24112         o_conv = ChannelUpdate_clone(&o_conv);
24113         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
24114         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
24115         return tag_ptr(ret_conv, true);
24116 }
24117
24118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24119         LDKDecodeError e_conv;
24120         e_conv.inner = untag_ptr(e);
24121         e_conv.is_owned = ptr_is_owned(e);
24122         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
24123         e_conv = DecodeError_clone(&e_conv);
24124         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
24125         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
24126         return tag_ptr(ret_conv, true);
24127 }
24128
24129 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24130         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(o);
24131         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
24132         return ret_conv;
24133 }
24134
24135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24136         if (!ptr_is_owned(_res)) return;
24137         void* _res_ptr = untag_ptr(_res);
24138         CHECK_ACCESS(_res_ptr);
24139         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
24140         FREE(untag_ptr(_res));
24141         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
24142 }
24143
24144 static inline uint64_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
24145         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
24146         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
24147         return tag_ptr(ret_conv, true);
24148 }
24149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24150         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(arg);
24151         int64_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
24152         return ret_conv;
24153 }
24154
24155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24156         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(orig);
24157         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
24158         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
24159         return tag_ptr(ret_conv, true);
24160 }
24161
24162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24163         LDKErrorMessage o_conv;
24164         o_conv.inner = untag_ptr(o);
24165         o_conv.is_owned = ptr_is_owned(o);
24166         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24167         o_conv = ErrorMessage_clone(&o_conv);
24168         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
24169         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
24170         return tag_ptr(ret_conv, true);
24171 }
24172
24173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24174         LDKDecodeError e_conv;
24175         e_conv.inner = untag_ptr(e);
24176         e_conv.is_owned = ptr_is_owned(e);
24177         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
24178         e_conv = DecodeError_clone(&e_conv);
24179         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
24180         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
24181         return tag_ptr(ret_conv, true);
24182 }
24183
24184 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24185         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(o);
24186         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
24187         return ret_conv;
24188 }
24189
24190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24191         if (!ptr_is_owned(_res)) return;
24192         void* _res_ptr = untag_ptr(_res);
24193         CHECK_ACCESS(_res_ptr);
24194         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
24195         FREE(untag_ptr(_res));
24196         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
24197 }
24198
24199 static inline uint64_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
24200         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
24201         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
24202         return tag_ptr(ret_conv, true);
24203 }
24204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24205         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(arg);
24206         int64_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
24207         return ret_conv;
24208 }
24209
24210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24211         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(orig);
24212         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
24213         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
24214         return tag_ptr(ret_conv, true);
24215 }
24216
24217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24218         LDKWarningMessage o_conv;
24219         o_conv.inner = untag_ptr(o);
24220         o_conv.is_owned = ptr_is_owned(o);
24221         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24222         o_conv = WarningMessage_clone(&o_conv);
24223         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
24224         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
24225         return tag_ptr(ret_conv, true);
24226 }
24227
24228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24229         LDKDecodeError e_conv;
24230         e_conv.inner = untag_ptr(e);
24231         e_conv.is_owned = ptr_is_owned(e);
24232         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
24233         e_conv = DecodeError_clone(&e_conv);
24234         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
24235         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
24236         return tag_ptr(ret_conv, true);
24237 }
24238
24239 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24240         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(o);
24241         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
24242         return ret_conv;
24243 }
24244
24245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24246         if (!ptr_is_owned(_res)) return;
24247         void* _res_ptr = untag_ptr(_res);
24248         CHECK_ACCESS(_res_ptr);
24249         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
24250         FREE(untag_ptr(_res));
24251         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
24252 }
24253
24254 static inline uint64_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
24255         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
24256         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
24257         return tag_ptr(ret_conv, true);
24258 }
24259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24260         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(arg);
24261         int64_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
24262         return ret_conv;
24263 }
24264
24265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24266         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(orig);
24267         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
24268         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
24269         return tag_ptr(ret_conv, true);
24270 }
24271
24272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24273         LDKUnsignedNodeAnnouncement o_conv;
24274         o_conv.inner = untag_ptr(o);
24275         o_conv.is_owned = ptr_is_owned(o);
24276         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24277         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
24278         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
24279         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
24280         return tag_ptr(ret_conv, true);
24281 }
24282
24283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24284         LDKDecodeError e_conv;
24285         e_conv.inner = untag_ptr(e);
24286         e_conv.is_owned = ptr_is_owned(e);
24287         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
24288         e_conv = DecodeError_clone(&e_conv);
24289         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
24290         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
24291         return tag_ptr(ret_conv, true);
24292 }
24293
24294 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24295         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(o);
24296         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
24297         return ret_conv;
24298 }
24299
24300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24301         if (!ptr_is_owned(_res)) return;
24302         void* _res_ptr = untag_ptr(_res);
24303         CHECK_ACCESS(_res_ptr);
24304         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
24305         FREE(untag_ptr(_res));
24306         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
24307 }
24308
24309 static inline uint64_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
24310         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
24311         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
24312         return tag_ptr(ret_conv, true);
24313 }
24314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24315         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
24316         int64_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
24317         return ret_conv;
24318 }
24319
24320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24321         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
24322         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
24323         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
24324         return tag_ptr(ret_conv, true);
24325 }
24326
24327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24328         LDKNodeAnnouncement o_conv;
24329         o_conv.inner = untag_ptr(o);
24330         o_conv.is_owned = ptr_is_owned(o);
24331         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24332         o_conv = NodeAnnouncement_clone(&o_conv);
24333         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
24334         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
24335         return tag_ptr(ret_conv, true);
24336 }
24337
24338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24339         LDKDecodeError e_conv;
24340         e_conv.inner = untag_ptr(e);
24341         e_conv.is_owned = ptr_is_owned(e);
24342         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
24343         e_conv = DecodeError_clone(&e_conv);
24344         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
24345         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
24346         return tag_ptr(ret_conv, true);
24347 }
24348
24349 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24350         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(o);
24351         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
24352         return ret_conv;
24353 }
24354
24355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24356         if (!ptr_is_owned(_res)) return;
24357         void* _res_ptr = untag_ptr(_res);
24358         CHECK_ACCESS(_res_ptr);
24359         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
24360         FREE(untag_ptr(_res));
24361         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
24362 }
24363
24364 static inline uint64_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
24365         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
24366         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
24367         return tag_ptr(ret_conv, true);
24368 }
24369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24370         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
24371         int64_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
24372         return ret_conv;
24373 }
24374
24375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24376         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
24377         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
24378         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
24379         return tag_ptr(ret_conv, true);
24380 }
24381
24382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24383         LDKQueryShortChannelIds o_conv;
24384         o_conv.inner = untag_ptr(o);
24385         o_conv.is_owned = ptr_is_owned(o);
24386         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24387         o_conv = QueryShortChannelIds_clone(&o_conv);
24388         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
24389         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
24390         return tag_ptr(ret_conv, true);
24391 }
24392
24393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24394         LDKDecodeError e_conv;
24395         e_conv.inner = untag_ptr(e);
24396         e_conv.is_owned = ptr_is_owned(e);
24397         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
24398         e_conv = DecodeError_clone(&e_conv);
24399         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
24400         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
24401         return tag_ptr(ret_conv, true);
24402 }
24403
24404 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24405         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(o);
24406         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
24407         return ret_conv;
24408 }
24409
24410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24411         if (!ptr_is_owned(_res)) return;
24412         void* _res_ptr = untag_ptr(_res);
24413         CHECK_ACCESS(_res_ptr);
24414         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
24415         FREE(untag_ptr(_res));
24416         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
24417 }
24418
24419 static inline uint64_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
24420         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
24421         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
24422         return tag_ptr(ret_conv, true);
24423 }
24424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24425         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(arg);
24426         int64_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
24427         return ret_conv;
24428 }
24429
24430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24431         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(orig);
24432         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
24433         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
24434         return tag_ptr(ret_conv, true);
24435 }
24436
24437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24438         LDKReplyShortChannelIdsEnd o_conv;
24439         o_conv.inner = untag_ptr(o);
24440         o_conv.is_owned = ptr_is_owned(o);
24441         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24442         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
24443         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
24444         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
24445         return tag_ptr(ret_conv, true);
24446 }
24447
24448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24449         LDKDecodeError e_conv;
24450         e_conv.inner = untag_ptr(e);
24451         e_conv.is_owned = ptr_is_owned(e);
24452         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
24453         e_conv = DecodeError_clone(&e_conv);
24454         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
24455         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
24456         return tag_ptr(ret_conv, true);
24457 }
24458
24459 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24460         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(o);
24461         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
24462         return ret_conv;
24463 }
24464
24465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24466         if (!ptr_is_owned(_res)) return;
24467         void* _res_ptr = untag_ptr(_res);
24468         CHECK_ACCESS(_res_ptr);
24469         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
24470         FREE(untag_ptr(_res));
24471         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
24472 }
24473
24474 static inline uint64_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
24475         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
24476         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
24477         return tag_ptr(ret_conv, true);
24478 }
24479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24480         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(arg);
24481         int64_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
24482         return ret_conv;
24483 }
24484
24485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24486         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(orig);
24487         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
24488         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
24489         return tag_ptr(ret_conv, true);
24490 }
24491
24492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24493         LDKQueryChannelRange o_conv;
24494         o_conv.inner = untag_ptr(o);
24495         o_conv.is_owned = ptr_is_owned(o);
24496         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24497         o_conv = QueryChannelRange_clone(&o_conv);
24498         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
24499         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
24500         return tag_ptr(ret_conv, true);
24501 }
24502
24503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24504         LDKDecodeError e_conv;
24505         e_conv.inner = untag_ptr(e);
24506         e_conv.is_owned = ptr_is_owned(e);
24507         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
24508         e_conv = DecodeError_clone(&e_conv);
24509         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
24510         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
24511         return tag_ptr(ret_conv, true);
24512 }
24513
24514 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24515         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(o);
24516         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
24517         return ret_conv;
24518 }
24519
24520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24521         if (!ptr_is_owned(_res)) return;
24522         void* _res_ptr = untag_ptr(_res);
24523         CHECK_ACCESS(_res_ptr);
24524         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
24525         FREE(untag_ptr(_res));
24526         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
24527 }
24528
24529 static inline uint64_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
24530         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
24531         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
24532         return tag_ptr(ret_conv, true);
24533 }
24534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24535         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(arg);
24536         int64_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
24537         return ret_conv;
24538 }
24539
24540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24541         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(orig);
24542         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
24543         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
24544         return tag_ptr(ret_conv, true);
24545 }
24546
24547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24548         LDKReplyChannelRange o_conv;
24549         o_conv.inner = untag_ptr(o);
24550         o_conv.is_owned = ptr_is_owned(o);
24551         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24552         o_conv = ReplyChannelRange_clone(&o_conv);
24553         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24554         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
24555         return tag_ptr(ret_conv, true);
24556 }
24557
24558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24559         LDKDecodeError e_conv;
24560         e_conv.inner = untag_ptr(e);
24561         e_conv.is_owned = ptr_is_owned(e);
24562         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
24563         e_conv = DecodeError_clone(&e_conv);
24564         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24565         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
24566         return tag_ptr(ret_conv, true);
24567 }
24568
24569 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24570         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(o);
24571         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
24572         return ret_conv;
24573 }
24574
24575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24576         if (!ptr_is_owned(_res)) return;
24577         void* _res_ptr = untag_ptr(_res);
24578         CHECK_ACCESS(_res_ptr);
24579         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
24580         FREE(untag_ptr(_res));
24581         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
24582 }
24583
24584 static inline uint64_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
24585         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24586         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
24587         return tag_ptr(ret_conv, true);
24588 }
24589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24590         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(arg);
24591         int64_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
24592         return ret_conv;
24593 }
24594
24595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24596         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(orig);
24597         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
24598         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
24599         return tag_ptr(ret_conv, true);
24600 }
24601
24602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24603         LDKGossipTimestampFilter o_conv;
24604         o_conv.inner = untag_ptr(o);
24605         o_conv.is_owned = ptr_is_owned(o);
24606         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24607         o_conv = GossipTimestampFilter_clone(&o_conv);
24608         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24609         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
24610         return tag_ptr(ret_conv, true);
24611 }
24612
24613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24614         LDKDecodeError e_conv;
24615         e_conv.inner = untag_ptr(e);
24616         e_conv.is_owned = ptr_is_owned(e);
24617         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
24618         e_conv = DecodeError_clone(&e_conv);
24619         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24620         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
24621         return tag_ptr(ret_conv, true);
24622 }
24623
24624 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24625         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(o);
24626         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
24627         return ret_conv;
24628 }
24629
24630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24631         if (!ptr_is_owned(_res)) return;
24632         void* _res_ptr = untag_ptr(_res);
24633         CHECK_ACCESS(_res_ptr);
24634         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
24635         FREE(untag_ptr(_res));
24636         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
24637 }
24638
24639 static inline uint64_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
24640         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24641         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
24642         return tag_ptr(ret_conv, true);
24643 }
24644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24645         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(arg);
24646         int64_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
24647         return ret_conv;
24648 }
24649
24650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24651         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(orig);
24652         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
24653         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
24654         return tag_ptr(ret_conv, true);
24655 }
24656
24657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PhantomRouteHintsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24658         LDKCVec_PhantomRouteHintsZ _res_constr;
24659         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24660         if (_res_constr.datalen > 0)
24661                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
24662         else
24663                 _res_constr.data = NULL;
24664         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24665         for (size_t t = 0; t < _res_constr.datalen; t++) {
24666                 int64_t _res_conv_19 = _res_vals[t];
24667                 LDKPhantomRouteHints _res_conv_19_conv;
24668                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
24669                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
24670                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
24671                 _res_constr.data[t] = _res_conv_19_conv;
24672         }
24673         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24674         CVec_PhantomRouteHintsZ_free(_res_constr);
24675 }
24676
24677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24678         LDKInvoice o_conv;
24679         o_conv.inner = untag_ptr(o);
24680         o_conv.is_owned = ptr_is_owned(o);
24681         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24682         o_conv = Invoice_clone(&o_conv);
24683         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
24684         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
24685         return tag_ptr(ret_conv, true);
24686 }
24687
24688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24689         void* e_ptr = untag_ptr(e);
24690         CHECK_ACCESS(e_ptr);
24691         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
24692         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)untag_ptr(e));
24693         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
24694         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
24695         return tag_ptr(ret_conv, true);
24696 }
24697
24698 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24699         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(o);
24700         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
24701         return ret_conv;
24702 }
24703
24704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24705         if (!ptr_is_owned(_res)) return;
24706         void* _res_ptr = untag_ptr(_res);
24707         CHECK_ACCESS(_res_ptr);
24708         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
24709         FREE(untag_ptr(_res));
24710         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
24711 }
24712
24713 static inline uint64_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
24714         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
24715         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
24716         return tag_ptr(ret_conv, true);
24717 }
24718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24719         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(arg);
24720         int64_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
24721         return ret_conv;
24722 }
24723
24724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24725         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(orig);
24726         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
24727         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
24728         return tag_ptr(ret_conv, true);
24729 }
24730
24731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
24732         void* o_ptr = untag_ptr(o);
24733         CHECK_ACCESS(o_ptr);
24734         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
24735         if (o_conv.free == LDKFilter_JCalls_free) {
24736                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24737                 LDKFilter_JCalls_cloned(&o_conv);
24738         }
24739         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
24740         *ret_copy = COption_FilterZ_some(o_conv);
24741         int64_t ret_ref = tag_ptr(ret_copy, true);
24742         return ret_ref;
24743 }
24744
24745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
24746         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
24747         *ret_copy = COption_FilterZ_none();
24748         int64_t ret_ref = tag_ptr(ret_copy, true);
24749         return ret_ref;
24750 }
24751
24752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24753         if (!ptr_is_owned(_res)) return;
24754         void* _res_ptr = untag_ptr(_res);
24755         CHECK_ACCESS(_res_ptr);
24756         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
24757         FREE(untag_ptr(_res));
24758         COption_FilterZ_free(_res_conv);
24759 }
24760
24761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24762         LDKLockedChannelMonitor o_conv;
24763         o_conv.inner = untag_ptr(o);
24764         o_conv.is_owned = ptr_is_owned(o);
24765         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24766         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
24767         
24768         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
24769         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
24770         return tag_ptr(ret_conv, true);
24771 }
24772
24773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
24774         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
24775         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
24776         return tag_ptr(ret_conv, true);
24777 }
24778
24779 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24780         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(o);
24781         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
24782         return ret_conv;
24783 }
24784
24785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24786         if (!ptr_is_owned(_res)) return;
24787         void* _res_ptr = untag_ptr(_res);
24788         CHECK_ACCESS(_res_ptr);
24789         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
24790         FREE(untag_ptr(_res));
24791         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
24792 }
24793
24794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
24795         LDKCVec_OutPointZ _res_constr;
24796         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
24797         if (_res_constr.datalen > 0)
24798                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
24799         else
24800                 _res_constr.data = NULL;
24801         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
24802         for (size_t k = 0; k < _res_constr.datalen; k++) {
24803                 int64_t _res_conv_10 = _res_vals[k];
24804                 LDKOutPoint _res_conv_10_conv;
24805                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
24806                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
24807                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
24808                 _res_constr.data[k] = _res_conv_10_conv;
24809         }
24810         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
24811         CVec_OutPointZ_free(_res_constr);
24812 }
24813
24814 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24815         if (!ptr_is_owned(this_ptr)) return;
24816         void* this_ptr_ptr = untag_ptr(this_ptr);
24817         CHECK_ACCESS(this_ptr_ptr);
24818         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
24819         FREE(untag_ptr(this_ptr));
24820         PaymentPurpose_free(this_ptr_conv);
24821 }
24822
24823 static inline uint64_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
24824         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
24825         *ret_copy = PaymentPurpose_clone(arg);
24826         int64_t ret_ref = tag_ptr(ret_copy, true);
24827         return ret_ref;
24828 }
24829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24830         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)untag_ptr(arg);
24831         int64_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
24832         return ret_conv;
24833 }
24834
24835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24836         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)untag_ptr(orig);
24837         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
24838         *ret_copy = PaymentPurpose_clone(orig_conv);
24839         int64_t ret_ref = tag_ptr(ret_copy, true);
24840         return ret_ref;
24841 }
24842
24843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
24844         LDKThirtyTwoBytes payment_preimage_ref;
24845         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
24846         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
24847         LDKThirtyTwoBytes payment_secret_ref;
24848         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
24849         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
24850         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
24851         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
24852         int64_t ret_ref = tag_ptr(ret_copy, true);
24853         return ret_ref;
24854 }
24855
24856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
24857         LDKThirtyTwoBytes a_ref;
24858         CHECK((*env)->GetArrayLength(env, a) == 32);
24859         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
24860         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
24861         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
24862         int64_t ret_ref = tag_ptr(ret_copy, true);
24863         return ret_ref;
24864 }
24865
24866 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1write(JNIEnv *env, jclass clz, int64_t obj) {
24867         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)untag_ptr(obj);
24868         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
24869         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24870         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24871         CVec_u8Z_free(ret_var);
24872         return ret_arr;
24873 }
24874
24875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24876         LDKu8slice ser_ref;
24877         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24878         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24879         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
24880         *ret_conv = PaymentPurpose_read(ser_ref);
24881         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24882         return tag_ptr(ret_conv, true);
24883 }
24884
24885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24886         if (!ptr_is_owned(this_ptr)) return;
24887         void* this_ptr_ptr = untag_ptr(this_ptr);
24888         CHECK_ACCESS(this_ptr_ptr);
24889         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
24890         FREE(untag_ptr(this_ptr));
24891         ClosureReason_free(this_ptr_conv);
24892 }
24893
24894 static inline uint64_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
24895         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24896         *ret_copy = ClosureReason_clone(arg);
24897         int64_t ret_ref = tag_ptr(ret_copy, true);
24898         return ret_ref;
24899 }
24900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24901         LDKClosureReason* arg_conv = (LDKClosureReason*)untag_ptr(arg);
24902         int64_t ret_conv = ClosureReason_clone_ptr(arg_conv);
24903         return ret_conv;
24904 }
24905
24906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24907         LDKClosureReason* orig_conv = (LDKClosureReason*)untag_ptr(orig);
24908         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24909         *ret_copy = ClosureReason_clone(orig_conv);
24910         int64_t ret_ref = tag_ptr(ret_copy, true);
24911         return ret_ref;
24912 }
24913
24914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
24915         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
24916         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24917         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
24918         int64_t ret_ref = tag_ptr(ret_copy, true);
24919         return ret_ref;
24920 }
24921
24922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
24923         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24924         *ret_copy = ClosureReason_holder_force_closed();
24925         int64_t ret_ref = tag_ptr(ret_copy, true);
24926         return ret_ref;
24927 }
24928
24929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
24930         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24931         *ret_copy = ClosureReason_cooperative_closure();
24932         int64_t ret_ref = tag_ptr(ret_copy, true);
24933         return ret_ref;
24934 }
24935
24936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
24937         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24938         *ret_copy = ClosureReason_commitment_tx_confirmed();
24939         int64_t ret_ref = tag_ptr(ret_copy, true);
24940         return ret_ref;
24941 }
24942
24943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
24944         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24945         *ret_copy = ClosureReason_funding_timed_out();
24946         int64_t ret_ref = tag_ptr(ret_copy, true);
24947         return ret_ref;
24948 }
24949
24950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
24951         LDKStr err_conv = java_to_owned_str(env, err);
24952         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24953         *ret_copy = ClosureReason_processing_error(err_conv);
24954         int64_t ret_ref = tag_ptr(ret_copy, true);
24955         return ret_ref;
24956 }
24957
24958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
24959         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24960         *ret_copy = ClosureReason_disconnected_peer();
24961         int64_t ret_ref = tag_ptr(ret_copy, true);
24962         return ret_ref;
24963 }
24964
24965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
24966         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
24967         *ret_copy = ClosureReason_outdated_channel_manager();
24968         int64_t ret_ref = tag_ptr(ret_copy, true);
24969         return ret_ref;
24970 }
24971
24972 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
24973         LDKClosureReason* obj_conv = (LDKClosureReason*)untag_ptr(obj);
24974         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
24975         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
24976         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
24977         CVec_u8Z_free(ret_var);
24978         return ret_arr;
24979 }
24980
24981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
24982         LDKu8slice ser_ref;
24983         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
24984         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
24985         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
24986         *ret_conv = ClosureReason_read(ser_ref);
24987         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
24988         return tag_ptr(ret_conv, true);
24989 }
24990
24991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24992         if (!ptr_is_owned(this_ptr)) return;
24993         void* this_ptr_ptr = untag_ptr(this_ptr);
24994         CHECK_ACCESS(this_ptr_ptr);
24995         LDKHTLCDestination this_ptr_conv = *(LDKHTLCDestination*)(this_ptr_ptr);
24996         FREE(untag_ptr(this_ptr));
24997         HTLCDestination_free(this_ptr_conv);
24998 }
24999
25000 static inline uint64_t HTLCDestination_clone_ptr(LDKHTLCDestination *NONNULL_PTR arg) {
25001         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
25002         *ret_copy = HTLCDestination_clone(arg);
25003         int64_t ret_ref = tag_ptr(ret_copy, true);
25004         return ret_ref;
25005 }
25006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25007         LDKHTLCDestination* arg_conv = (LDKHTLCDestination*)untag_ptr(arg);
25008         int64_t ret_conv = HTLCDestination_clone_ptr(arg_conv);
25009         return ret_conv;
25010 }
25011
25012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25013         LDKHTLCDestination* orig_conv = (LDKHTLCDestination*)untag_ptr(orig);
25014         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
25015         *ret_copy = HTLCDestination_clone(orig_conv);
25016         int64_t ret_ref = tag_ptr(ret_copy, true);
25017         return ret_ref;
25018 }
25019
25020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1next_1hop_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int8_tArray channel_id) {
25021         LDKPublicKey node_id_ref;
25022         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25023         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25024         LDKThirtyTwoBytes channel_id_ref;
25025         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
25026         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
25027         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
25028         *ret_copy = HTLCDestination_next_hop_channel(node_id_ref, channel_id_ref);
25029         int64_t ret_ref = tag_ptr(ret_copy, true);
25030         return ret_ref;
25031 }
25032
25033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1unknown_1next_1hop(JNIEnv *env, jclass clz, int64_t requested_forward_scid) {
25034         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
25035         *ret_copy = HTLCDestination_unknown_next_hop(requested_forward_scid);
25036         int64_t ret_ref = tag_ptr(ret_copy, true);
25037         return ret_ref;
25038 }
25039
25040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1failed_1payment(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
25041         LDKThirtyTwoBytes payment_hash_ref;
25042         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25043         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25044         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
25045         *ret_copy = HTLCDestination_failed_payment(payment_hash_ref);
25046         int64_t ret_ref = tag_ptr(ret_copy, true);
25047         return ret_ref;
25048 }
25049
25050 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1write(JNIEnv *env, jclass clz, int64_t obj) {
25051         LDKHTLCDestination* obj_conv = (LDKHTLCDestination*)untag_ptr(obj);
25052         LDKCVec_u8Z ret_var = HTLCDestination_write(obj_conv);
25053         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25054         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25055         CVec_u8Z_free(ret_var);
25056         return ret_arr;
25057 }
25058
25059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25060         LDKu8slice ser_ref;
25061         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25062         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25063         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
25064         *ret_conv = HTLCDestination_read(ser_ref);
25065         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25066         return tag_ptr(ret_conv, true);
25067 }
25068
25069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25070         if (!ptr_is_owned(this_ptr)) return;
25071         void* this_ptr_ptr = untag_ptr(this_ptr);
25072         CHECK_ACCESS(this_ptr_ptr);
25073         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
25074         FREE(untag_ptr(this_ptr));
25075         Event_free(this_ptr_conv);
25076 }
25077
25078 static inline uint64_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
25079         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25080         *ret_copy = Event_clone(arg);
25081         int64_t ret_ref = tag_ptr(ret_copy, true);
25082         return ret_ref;
25083 }
25084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25085         LDKEvent* arg_conv = (LDKEvent*)untag_ptr(arg);
25086         int64_t ret_conv = Event_clone_ptr(arg_conv);
25087         return ret_conv;
25088 }
25089
25090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25091         LDKEvent* orig_conv = (LDKEvent*)untag_ptr(orig);
25092         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25093         *ret_copy = Event_clone(orig_conv);
25094         int64_t ret_ref = tag_ptr(ret_copy, true);
25095         return ret_ref;
25096 }
25097
25098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1funding_1generation_1ready(JNIEnv *env, jclass clz, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t channel_value_satoshis, int8_tArray output_script, int64_t user_channel_id) {
25099         LDKThirtyTwoBytes temporary_channel_id_ref;
25100         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
25101         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
25102         LDKPublicKey counterparty_node_id_ref;
25103         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
25104         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
25105         LDKCVec_u8Z output_script_ref;
25106         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
25107         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
25108         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
25109         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25110         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
25111         int64_t ret_ref = tag_ptr(ret_copy, true);
25112         return ret_ref;
25113 }
25114
25115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t amount_msat, int64_t purpose) {
25116         LDKThirtyTwoBytes payment_hash_ref;
25117         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25118         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25119         void* purpose_ptr = untag_ptr(purpose);
25120         CHECK_ACCESS(purpose_ptr);
25121         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
25122         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
25123         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25124         *ret_copy = Event_payment_received(payment_hash_ref, amount_msat, purpose_conv);
25125         int64_t ret_ref = tag_ptr(ret_copy, true);
25126         return ret_ref;
25127 }
25128
25129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1claimed(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t amount_msat, int64_t purpose) {
25130         LDKThirtyTwoBytes payment_hash_ref;
25131         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25132         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25133         void* purpose_ptr = untag_ptr(purpose);
25134         CHECK_ACCESS(purpose_ptr);
25135         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
25136         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
25137         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25138         *ret_copy = Event_payment_claimed(payment_hash_ref, amount_msat, purpose_conv);
25139         int64_t ret_ref = tag_ptr(ret_copy, true);
25140         return ret_ref;
25141 }
25142
25143 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) {
25144         LDKThirtyTwoBytes payment_id_ref;
25145         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
25146         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
25147         LDKThirtyTwoBytes payment_preimage_ref;
25148         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
25149         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
25150         LDKThirtyTwoBytes payment_hash_ref;
25151         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25152         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25153         void* fee_paid_msat_ptr = untag_ptr(fee_paid_msat);
25154         CHECK_ACCESS(fee_paid_msat_ptr);
25155         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
25156         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_paid_msat));
25157         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25158         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
25159         int64_t ret_ref = tag_ptr(ret_copy, true);
25160         return ret_ref;
25161 }
25162
25163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash) {
25164         LDKThirtyTwoBytes payment_id_ref;
25165         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
25166         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
25167         LDKThirtyTwoBytes payment_hash_ref;
25168         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25169         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25170         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25171         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
25172         int64_t ret_ref = tag_ptr(ret_copy, true);
25173         return ret_ref;
25174 }
25175
25176 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) {
25177         LDKThirtyTwoBytes payment_id_ref;
25178         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
25179         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
25180         LDKThirtyTwoBytes payment_hash_ref;
25181         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25182         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25183         LDKCVec_RouteHopZ path_constr;
25184         path_constr.datalen = (*env)->GetArrayLength(env, path);
25185         if (path_constr.datalen > 0)
25186                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
25187         else
25188                 path_constr.data = NULL;
25189         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
25190         for (size_t k = 0; k < path_constr.datalen; k++) {
25191                 int64_t path_conv_10 = path_vals[k];
25192                 LDKRouteHop path_conv_10_conv;
25193                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
25194                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
25195                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
25196                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
25197                 path_constr.data[k] = path_conv_10_conv;
25198         }
25199         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
25200         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25201         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
25202         int64_t ret_ref = tag_ptr(ret_copy, true);
25203         return ret_ref;
25204 }
25205
25206 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 payment_failed_permanently, int64_t network_update, jboolean all_paths_failed, int64_tArray path, int64_t short_channel_id, int64_t retry) {
25207         LDKThirtyTwoBytes payment_id_ref;
25208         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
25209         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
25210         LDKThirtyTwoBytes payment_hash_ref;
25211         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25212         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25213         void* network_update_ptr = untag_ptr(network_update);
25214         CHECK_ACCESS(network_update_ptr);
25215         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
25216         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(network_update));
25217         LDKCVec_RouteHopZ path_constr;
25218         path_constr.datalen = (*env)->GetArrayLength(env, path);
25219         if (path_constr.datalen > 0)
25220                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
25221         else
25222                 path_constr.data = NULL;
25223         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
25224         for (size_t k = 0; k < path_constr.datalen; k++) {
25225                 int64_t path_conv_10 = path_vals[k];
25226                 LDKRouteHop path_conv_10_conv;
25227                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
25228                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
25229                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
25230                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
25231                 path_constr.data[k] = path_conv_10_conv;
25232         }
25233         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
25234         void* short_channel_id_ptr = untag_ptr(short_channel_id);
25235         CHECK_ACCESS(short_channel_id_ptr);
25236         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
25237         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
25238         LDKRouteParameters retry_conv;
25239         retry_conv.inner = untag_ptr(retry);
25240         retry_conv.is_owned = ptr_is_owned(retry);
25241         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
25242         retry_conv = RouteParameters_clone(&retry_conv);
25243         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25244         *ret_copy = Event_payment_path_failed(payment_id_ref, payment_hash_ref, payment_failed_permanently, network_update_conv, all_paths_failed, path_constr, short_channel_id_conv, retry_conv);
25245         int64_t ret_ref = tag_ptr(ret_copy, true);
25246         return ret_ref;
25247 }
25248
25249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1probe_1successful(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, int64_tArray path) {
25250         LDKThirtyTwoBytes payment_id_ref;
25251         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
25252         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
25253         LDKThirtyTwoBytes payment_hash_ref;
25254         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25255         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25256         LDKCVec_RouteHopZ path_constr;
25257         path_constr.datalen = (*env)->GetArrayLength(env, path);
25258         if (path_constr.datalen > 0)
25259                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
25260         else
25261                 path_constr.data = NULL;
25262         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
25263         for (size_t k = 0; k < path_constr.datalen; k++) {
25264                 int64_t path_conv_10 = path_vals[k];
25265                 LDKRouteHop path_conv_10_conv;
25266                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
25267                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
25268                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
25269                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
25270                 path_constr.data[k] = path_conv_10_conv;
25271         }
25272         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
25273         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25274         *ret_copy = Event_probe_successful(payment_id_ref, payment_hash_ref, path_constr);
25275         int64_t ret_ref = tag_ptr(ret_copy, true);
25276         return ret_ref;
25277 }
25278
25279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1probe_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash, int64_tArray path, int64_t short_channel_id) {
25280         LDKThirtyTwoBytes payment_id_ref;
25281         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
25282         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
25283         LDKThirtyTwoBytes payment_hash_ref;
25284         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
25285         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
25286         LDKCVec_RouteHopZ path_constr;
25287         path_constr.datalen = (*env)->GetArrayLength(env, path);
25288         if (path_constr.datalen > 0)
25289                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
25290         else
25291                 path_constr.data = NULL;
25292         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
25293         for (size_t k = 0; k < path_constr.datalen; k++) {
25294                 int64_t path_conv_10 = path_vals[k];
25295                 LDKRouteHop path_conv_10_conv;
25296                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
25297                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
25298                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
25299                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
25300                 path_constr.data[k] = path_conv_10_conv;
25301         }
25302         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
25303         void* short_channel_id_ptr = untag_ptr(short_channel_id);
25304         CHECK_ACCESS(short_channel_id_ptr);
25305         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
25306         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
25307         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25308         *ret_copy = Event_probe_failed(payment_id_ref, payment_hash_ref, path_constr, short_channel_id_conv);
25309         int64_t ret_ref = tag_ptr(ret_copy, true);
25310         return ret_ref;
25311 }
25312
25313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
25314         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25315         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
25316         int64_t ret_ref = tag_ptr(ret_copy, true);
25317         return ret_ref;
25318 }
25319
25320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
25321         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
25322         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
25323         if (outputs_constr.datalen > 0)
25324                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
25325         else
25326                 outputs_constr.data = NULL;
25327         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
25328         for (size_t b = 0; b < outputs_constr.datalen; b++) {
25329                 int64_t outputs_conv_27 = outputs_vals[b];
25330                 void* outputs_conv_27_ptr = untag_ptr(outputs_conv_27);
25331                 CHECK_ACCESS(outputs_conv_27_ptr);
25332                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
25333                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(outputs_conv_27));
25334                 outputs_constr.data[b] = outputs_conv_27_conv;
25335         }
25336         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
25337         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25338         *ret_copy = Event_spendable_outputs(outputs_constr);
25339         int64_t ret_ref = tag_ptr(ret_copy, true);
25340         return ret_ref;
25341 }
25342
25343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1forwarded(JNIEnv *env, jclass clz, int8_tArray prev_channel_id, int8_tArray next_channel_id, int64_t fee_earned_msat, jboolean claim_from_onchain_tx) {
25344         LDKThirtyTwoBytes prev_channel_id_ref;
25345         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
25346         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
25347         LDKThirtyTwoBytes next_channel_id_ref;
25348         CHECK((*env)->GetArrayLength(env, next_channel_id) == 32);
25349         (*env)->GetByteArrayRegion(env, next_channel_id, 0, 32, next_channel_id_ref.data);
25350         void* fee_earned_msat_ptr = untag_ptr(fee_earned_msat);
25351         CHECK_ACCESS(fee_earned_msat_ptr);
25352         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
25353         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_earned_msat));
25354         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25355         *ret_copy = Event_payment_forwarded(prev_channel_id_ref, next_channel_id_ref, fee_earned_msat_conv, claim_from_onchain_tx);
25356         int64_t ret_ref = tag_ptr(ret_copy, true);
25357         return ret_ref;
25358 }
25359
25360 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) {
25361         LDKThirtyTwoBytes channel_id_ref;
25362         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
25363         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
25364         void* reason_ptr = untag_ptr(reason);
25365         CHECK_ACCESS(reason_ptr);
25366         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
25367         reason_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(reason));
25368         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25369         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
25370         int64_t ret_ref = tag_ptr(ret_copy, true);
25371         return ret_ref;
25372 }
25373
25374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
25375         LDKThirtyTwoBytes channel_id_ref;
25376         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
25377         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
25378         LDKTransaction transaction_ref;
25379         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
25380         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
25381         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
25382         transaction_ref.data_is_owned = true;
25383         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25384         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
25385         int64_t ret_ref = tag_ptr(ret_copy, true);
25386         return ret_ref;
25387 }
25388
25389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1open_1channel_1request(JNIEnv *env, jclass clz, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t funding_satoshis, int64_t push_msat, int64_t channel_type) {
25390         LDKThirtyTwoBytes temporary_channel_id_ref;
25391         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
25392         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
25393         LDKPublicKey counterparty_node_id_ref;
25394         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
25395         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
25396         LDKChannelTypeFeatures channel_type_conv;
25397         channel_type_conv.inner = untag_ptr(channel_type);
25398         channel_type_conv.is_owned = ptr_is_owned(channel_type);
25399         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
25400         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
25401         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25402         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
25403         int64_t ret_ref = tag_ptr(ret_copy, true);
25404         return ret_ref;
25405 }
25406
25407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1htlchandling_1failed(JNIEnv *env, jclass clz, int8_tArray prev_channel_id, int64_t failed_next_destination) {
25408         LDKThirtyTwoBytes prev_channel_id_ref;
25409         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
25410         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
25411         void* failed_next_destination_ptr = untag_ptr(failed_next_destination);
25412         CHECK_ACCESS(failed_next_destination_ptr);
25413         LDKHTLCDestination failed_next_destination_conv = *(LDKHTLCDestination*)(failed_next_destination_ptr);
25414         failed_next_destination_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(failed_next_destination));
25415         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
25416         *ret_copy = Event_htlchandling_failed(prev_channel_id_ref, failed_next_destination_conv);
25417         int64_t ret_ref = tag_ptr(ret_copy, true);
25418         return ret_ref;
25419 }
25420
25421 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
25422         LDKEvent* obj_conv = (LDKEvent*)untag_ptr(obj);
25423         LDKCVec_u8Z ret_var = Event_write(obj_conv);
25424         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25425         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25426         CVec_u8Z_free(ret_var);
25427         return ret_arr;
25428 }
25429
25430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
25431         LDKu8slice ser_ref;
25432         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25433         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25434         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
25435         *ret_conv = Event_read(ser_ref);
25436         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25437         return tag_ptr(ret_conv, true);
25438 }
25439
25440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25441         if (!ptr_is_owned(this_ptr)) return;
25442         void* this_ptr_ptr = untag_ptr(this_ptr);
25443         CHECK_ACCESS(this_ptr_ptr);
25444         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
25445         FREE(untag_ptr(this_ptr));
25446         MessageSendEvent_free(this_ptr_conv);
25447 }
25448
25449 static inline uint64_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
25450         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25451         *ret_copy = MessageSendEvent_clone(arg);
25452         int64_t ret_ref = tag_ptr(ret_copy, true);
25453         return ret_ref;
25454 }
25455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25456         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)untag_ptr(arg);
25457         int64_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
25458         return ret_conv;
25459 }
25460
25461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25462         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)untag_ptr(orig);
25463         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25464         *ret_copy = MessageSendEvent_clone(orig_conv);
25465         int64_t ret_ref = tag_ptr(ret_copy, true);
25466         return ret_ref;
25467 }
25468
25469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25470         LDKPublicKey node_id_ref;
25471         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25472         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25473         LDKAcceptChannel msg_conv;
25474         msg_conv.inner = untag_ptr(msg);
25475         msg_conv.is_owned = ptr_is_owned(msg);
25476         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25477         msg_conv = AcceptChannel_clone(&msg_conv);
25478         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25479         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
25480         int64_t ret_ref = tag_ptr(ret_copy, true);
25481         return ret_ref;
25482 }
25483
25484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25485         LDKPublicKey node_id_ref;
25486         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25487         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25488         LDKOpenChannel msg_conv;
25489         msg_conv.inner = untag_ptr(msg);
25490         msg_conv.is_owned = ptr_is_owned(msg);
25491         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25492         msg_conv = OpenChannel_clone(&msg_conv);
25493         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25494         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
25495         int64_t ret_ref = tag_ptr(ret_copy, true);
25496         return ret_ref;
25497 }
25498
25499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25500         LDKPublicKey node_id_ref;
25501         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25502         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25503         LDKFundingCreated msg_conv;
25504         msg_conv.inner = untag_ptr(msg);
25505         msg_conv.is_owned = ptr_is_owned(msg);
25506         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25507         msg_conv = FundingCreated_clone(&msg_conv);
25508         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25509         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
25510         int64_t ret_ref = tag_ptr(ret_copy, true);
25511         return ret_ref;
25512 }
25513
25514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25515         LDKPublicKey node_id_ref;
25516         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25517         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25518         LDKFundingSigned msg_conv;
25519         msg_conv.inner = untag_ptr(msg);
25520         msg_conv.is_owned = ptr_is_owned(msg);
25521         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25522         msg_conv = FundingSigned_clone(&msg_conv);
25523         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25524         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
25525         int64_t ret_ref = tag_ptr(ret_copy, true);
25526         return ret_ref;
25527 }
25528
25529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1ready(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25530         LDKPublicKey node_id_ref;
25531         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25532         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25533         LDKChannelReady msg_conv;
25534         msg_conv.inner = untag_ptr(msg);
25535         msg_conv.is_owned = ptr_is_owned(msg);
25536         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25537         msg_conv = ChannelReady_clone(&msg_conv);
25538         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25539         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
25540         int64_t ret_ref = tag_ptr(ret_copy, true);
25541         return ret_ref;
25542 }
25543
25544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25545         LDKPublicKey node_id_ref;
25546         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25547         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25548         LDKAnnouncementSignatures msg_conv;
25549         msg_conv.inner = untag_ptr(msg);
25550         msg_conv.is_owned = ptr_is_owned(msg);
25551         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25552         msg_conv = AnnouncementSignatures_clone(&msg_conv);
25553         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25554         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
25555         int64_t ret_ref = tag_ptr(ret_copy, true);
25556         return ret_ref;
25557 }
25558
25559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
25560         LDKPublicKey node_id_ref;
25561         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25562         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25563         LDKCommitmentUpdate updates_conv;
25564         updates_conv.inner = untag_ptr(updates);
25565         updates_conv.is_owned = ptr_is_owned(updates);
25566         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
25567         updates_conv = CommitmentUpdate_clone(&updates_conv);
25568         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25569         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
25570         int64_t ret_ref = tag_ptr(ret_copy, true);
25571         return ret_ref;
25572 }
25573
25574 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) {
25575         LDKPublicKey node_id_ref;
25576         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25577         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25578         LDKRevokeAndACK msg_conv;
25579         msg_conv.inner = untag_ptr(msg);
25580         msg_conv.is_owned = ptr_is_owned(msg);
25581         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25582         msg_conv = RevokeAndACK_clone(&msg_conv);
25583         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25584         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
25585         int64_t ret_ref = tag_ptr(ret_copy, true);
25586         return ret_ref;
25587 }
25588
25589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25590         LDKPublicKey node_id_ref;
25591         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25592         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25593         LDKClosingSigned msg_conv;
25594         msg_conv.inner = untag_ptr(msg);
25595         msg_conv.is_owned = ptr_is_owned(msg);
25596         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25597         msg_conv = ClosingSigned_clone(&msg_conv);
25598         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25599         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
25600         int64_t ret_ref = tag_ptr(ret_copy, true);
25601         return ret_ref;
25602 }
25603
25604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25605         LDKPublicKey node_id_ref;
25606         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25607         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25608         LDKShutdown msg_conv;
25609         msg_conv.inner = untag_ptr(msg);
25610         msg_conv.is_owned = ptr_is_owned(msg);
25611         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25612         msg_conv = Shutdown_clone(&msg_conv);
25613         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25614         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
25615         int64_t ret_ref = tag_ptr(ret_copy, true);
25616         return ret_ref;
25617 }
25618
25619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25620         LDKPublicKey node_id_ref;
25621         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25622         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25623         LDKChannelReestablish msg_conv;
25624         msg_conv.inner = untag_ptr(msg);
25625         msg_conv.is_owned = ptr_is_owned(msg);
25626         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25627         msg_conv = ChannelReestablish_clone(&msg_conv);
25628         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25629         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
25630         int64_t ret_ref = tag_ptr(ret_copy, true);
25631         return ret_ref;
25632 }
25633
25634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1announcement(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg, int64_t update_msg) {
25635         LDKPublicKey node_id_ref;
25636         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25637         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25638         LDKChannelAnnouncement msg_conv;
25639         msg_conv.inner = untag_ptr(msg);
25640         msg_conv.is_owned = ptr_is_owned(msg);
25641         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25642         msg_conv = ChannelAnnouncement_clone(&msg_conv);
25643         LDKChannelUpdate update_msg_conv;
25644         update_msg_conv.inner = untag_ptr(update_msg);
25645         update_msg_conv.is_owned = ptr_is_owned(update_msg);
25646         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
25647         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
25648         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25649         *ret_copy = MessageSendEvent_send_channel_announcement(node_id_ref, msg_conv, update_msg_conv);
25650         int64_t ret_ref = tag_ptr(ret_copy, true);
25651         return ret_ref;
25652 }
25653
25654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
25655         LDKChannelAnnouncement msg_conv;
25656         msg_conv.inner = untag_ptr(msg);
25657         msg_conv.is_owned = ptr_is_owned(msg);
25658         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25659         msg_conv = ChannelAnnouncement_clone(&msg_conv);
25660         LDKChannelUpdate update_msg_conv;
25661         update_msg_conv.inner = untag_ptr(update_msg);
25662         update_msg_conv.is_owned = ptr_is_owned(update_msg);
25663         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
25664         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
25665         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25666         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
25667         int64_t ret_ref = tag_ptr(ret_copy, true);
25668         return ret_ref;
25669 }
25670
25671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
25672         LDKChannelUpdate msg_conv;
25673         msg_conv.inner = untag_ptr(msg);
25674         msg_conv.is_owned = ptr_is_owned(msg);
25675         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25676         msg_conv = ChannelUpdate_clone(&msg_conv);
25677         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25678         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
25679         int64_t ret_ref = tag_ptr(ret_copy, true);
25680         return ret_ref;
25681 }
25682
25683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25684         LDKPublicKey node_id_ref;
25685         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25686         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25687         LDKChannelUpdate msg_conv;
25688         msg_conv.inner = untag_ptr(msg);
25689         msg_conv.is_owned = ptr_is_owned(msg);
25690         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25691         msg_conv = ChannelUpdate_clone(&msg_conv);
25692         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25693         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
25694         int64_t ret_ref = tag_ptr(ret_copy, true);
25695         return ret_ref;
25696 }
25697
25698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
25699         LDKPublicKey node_id_ref;
25700         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25701         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25702         void* action_ptr = untag_ptr(action);
25703         CHECK_ACCESS(action_ptr);
25704         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
25705         action_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action));
25706         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25707         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
25708         int64_t ret_ref = tag_ptr(ret_copy, true);
25709         return ret_ref;
25710 }
25711
25712 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) {
25713         LDKPublicKey node_id_ref;
25714         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25715         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25716         LDKQueryChannelRange msg_conv;
25717         msg_conv.inner = untag_ptr(msg);
25718         msg_conv.is_owned = ptr_is_owned(msg);
25719         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25720         msg_conv = QueryChannelRange_clone(&msg_conv);
25721         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25722         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
25723         int64_t ret_ref = tag_ptr(ret_copy, true);
25724         return ret_ref;
25725 }
25726
25727 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) {
25728         LDKPublicKey node_id_ref;
25729         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25730         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25731         LDKQueryShortChannelIds msg_conv;
25732         msg_conv.inner = untag_ptr(msg);
25733         msg_conv.is_owned = ptr_is_owned(msg);
25734         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25735         msg_conv = QueryShortChannelIds_clone(&msg_conv);
25736         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25737         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
25738         int64_t ret_ref = tag_ptr(ret_copy, true);
25739         return ret_ref;
25740 }
25741
25742 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) {
25743         LDKPublicKey node_id_ref;
25744         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25745         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25746         LDKReplyChannelRange msg_conv;
25747         msg_conv.inner = untag_ptr(msg);
25748         msg_conv.is_owned = ptr_is_owned(msg);
25749         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25750         msg_conv = ReplyChannelRange_clone(&msg_conv);
25751         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25752         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
25753         int64_t ret_ref = tag_ptr(ret_copy, true);
25754         return ret_ref;
25755 }
25756
25757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1gossip_1timestamp_1filter(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
25758         LDKPublicKey node_id_ref;
25759         CHECK((*env)->GetArrayLength(env, node_id) == 33);
25760         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
25761         LDKGossipTimestampFilter msg_conv;
25762         msg_conv.inner = untag_ptr(msg);
25763         msg_conv.is_owned = ptr_is_owned(msg);
25764         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
25765         msg_conv = GossipTimestampFilter_clone(&msg_conv);
25766         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
25767         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
25768         int64_t ret_ref = tag_ptr(ret_copy, true);
25769         return ret_ref;
25770 }
25771
25772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25773         if (!ptr_is_owned(this_ptr)) return;
25774         void* this_ptr_ptr = untag_ptr(this_ptr);
25775         CHECK_ACCESS(this_ptr_ptr);
25776         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
25777         FREE(untag_ptr(this_ptr));
25778         MessageSendEventsProvider_free(this_ptr_conv);
25779 }
25780
25781 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25782         if (!ptr_is_owned(this_ptr)) return;
25783         void* this_ptr_ptr = untag_ptr(this_ptr);
25784         CHECK_ACCESS(this_ptr_ptr);
25785         LDKOnionMessageProvider this_ptr_conv = *(LDKOnionMessageProvider*)(this_ptr_ptr);
25786         FREE(untag_ptr(this_ptr));
25787         OnionMessageProvider_free(this_ptr_conv);
25788 }
25789
25790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25791         if (!ptr_is_owned(this_ptr)) return;
25792         void* this_ptr_ptr = untag_ptr(this_ptr);
25793         CHECK_ACCESS(this_ptr_ptr);
25794         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
25795         FREE(untag_ptr(this_ptr));
25796         EventsProvider_free(this_ptr_conv);
25797 }
25798
25799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25800         if (!ptr_is_owned(this_ptr)) return;
25801         void* this_ptr_ptr = untag_ptr(this_ptr);
25802         CHECK_ACCESS(this_ptr_ptr);
25803         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
25804         FREE(untag_ptr(this_ptr));
25805         EventHandler_free(this_ptr_conv);
25806 }
25807
25808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25809         if (!ptr_is_owned(this_ptr)) return;
25810         void* this_ptr_ptr = untag_ptr(this_ptr);
25811         CHECK_ACCESS(this_ptr_ptr);
25812         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
25813         FREE(untag_ptr(this_ptr));
25814         APIError_free(this_ptr_conv);
25815 }
25816
25817 static inline uint64_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
25818         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25819         *ret_copy = APIError_clone(arg);
25820         int64_t ret_ref = tag_ptr(ret_copy, true);
25821         return ret_ref;
25822 }
25823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25824         LDKAPIError* arg_conv = (LDKAPIError*)untag_ptr(arg);
25825         int64_t ret_conv = APIError_clone_ptr(arg_conv);
25826         return ret_conv;
25827 }
25828
25829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25830         LDKAPIError* orig_conv = (LDKAPIError*)untag_ptr(orig);
25831         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25832         *ret_copy = APIError_clone(orig_conv);
25833         int64_t ret_ref = tag_ptr(ret_copy, true);
25834         return ret_ref;
25835 }
25836
25837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
25838         LDKStr err_conv = java_to_owned_str(env, err);
25839         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25840         *ret_copy = APIError_apimisuse_error(err_conv);
25841         int64_t ret_ref = tag_ptr(ret_copy, true);
25842         return ret_ref;
25843 }
25844
25845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
25846         LDKStr err_conv = java_to_owned_str(env, err);
25847         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25848         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
25849         int64_t ret_ref = tag_ptr(ret_copy, true);
25850         return ret_ref;
25851 }
25852
25853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
25854         LDKStr err_conv = java_to_owned_str(env, err);
25855         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25856         *ret_copy = APIError_route_error(err_conv);
25857         int64_t ret_ref = tag_ptr(ret_copy, true);
25858         return ret_ref;
25859 }
25860
25861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
25862         LDKStr err_conv = java_to_owned_str(env, err);
25863         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25864         *ret_copy = APIError_channel_unavailable(err_conv);
25865         int64_t ret_ref = tag_ptr(ret_copy, true);
25866         return ret_ref;
25867 }
25868
25869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
25870         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25871         *ret_copy = APIError_monitor_update_failed();
25872         int64_t ret_ref = tag_ptr(ret_copy, true);
25873         return ret_ref;
25874 }
25875
25876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
25877         LDKShutdownScript script_conv;
25878         script_conv.inner = untag_ptr(script);
25879         script_conv.is_owned = ptr_is_owned(script);
25880         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
25881         script_conv = ShutdownScript_clone(&script_conv);
25882         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
25883         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
25884         int64_t ret_ref = tag_ptr(ret_copy, true);
25885         return ret_ref;
25886 }
25887
25888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25889         LDKBigSize this_obj_conv;
25890         this_obj_conv.inner = untag_ptr(this_obj);
25891         this_obj_conv.is_owned = ptr_is_owned(this_obj);
25892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25893         BigSize_free(this_obj_conv);
25894 }
25895
25896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
25897         LDKBigSize this_ptr_conv;
25898         this_ptr_conv.inner = untag_ptr(this_ptr);
25899         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25901         this_ptr_conv.is_owned = false;
25902         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
25903         return ret_conv;
25904 }
25905
25906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25907         LDKBigSize this_ptr_conv;
25908         this_ptr_conv.inner = untag_ptr(this_ptr);
25909         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
25910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25911         this_ptr_conv.is_owned = false;
25912         BigSize_set_a(&this_ptr_conv, val);
25913 }
25914
25915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
25916         LDKBigSize ret_var = BigSize_new(a_arg);
25917         int64_t ret_ref = 0;
25918         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25919         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25920         return ret_ref;
25921 }
25922
25923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Hostname_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25924         LDKHostname this_obj_conv;
25925         this_obj_conv.inner = untag_ptr(this_obj);
25926         this_obj_conv.is_owned = ptr_is_owned(this_obj);
25927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25928         Hostname_free(this_obj_conv);
25929 }
25930
25931 static inline uint64_t Hostname_clone_ptr(LDKHostname *NONNULL_PTR arg) {
25932         LDKHostname ret_var = Hostname_clone(arg);
25933         int64_t ret_ref = 0;
25934         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25935         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25936         return ret_ref;
25937 }
25938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25939         LDKHostname arg_conv;
25940         arg_conv.inner = untag_ptr(arg);
25941         arg_conv.is_owned = ptr_is_owned(arg);
25942         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25943         arg_conv.is_owned = false;
25944         int64_t ret_conv = Hostname_clone_ptr(&arg_conv);
25945         return ret_conv;
25946 }
25947
25948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25949         LDKHostname orig_conv;
25950         orig_conv.inner = untag_ptr(orig);
25951         orig_conv.is_owned = ptr_is_owned(orig);
25952         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25953         orig_conv.is_owned = false;
25954         LDKHostname ret_var = Hostname_clone(&orig_conv);
25955         int64_t ret_ref = 0;
25956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25957         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
25958         return ret_ref;
25959 }
25960
25961 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_Hostname_1len(JNIEnv *env, jclass clz, int64_t this_arg) {
25962         LDKHostname this_arg_conv;
25963         this_arg_conv.inner = untag_ptr(this_arg);
25964         this_arg_conv.is_owned = ptr_is_owned(this_arg);
25965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25966         this_arg_conv.is_owned = false;
25967         int8_t ret_conv = Hostname_len(&this_arg_conv);
25968         return ret_conv;
25969 }
25970
25971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
25972         LDKu8slice msg_ref;
25973         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
25974         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
25975         unsigned char sk_arr[32];
25976         CHECK((*env)->GetArrayLength(env, sk) == 32);
25977         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
25978         unsigned char (*sk_ref)[32] = &sk_arr;
25979         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
25980         *ret_conv = sign(msg_ref, sk_ref);
25981         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
25982         return tag_ptr(ret_conv, true);
25983 }
25984
25985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
25986         LDKu8slice msg_ref;
25987         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
25988         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
25989         LDKStr sig_conv = java_to_owned_str(env, sig);
25990         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
25991         *ret_conv = recover_pk(msg_ref, sig_conv);
25992         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
25993         return tag_ptr(ret_conv, true);
25994 }
25995
25996 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
25997         LDKu8slice msg_ref;
25998         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
25999         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
26000         LDKStr sig_conv = java_to_owned_str(env, sig);
26001         LDKPublicKey pk_ref;
26002         CHECK((*env)->GetArrayLength(env, pk) == 33);
26003         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
26004         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
26005         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
26006         return ret_conv;
26007 }
26008
26009 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_construct_1invoice_1preimage(JNIEnv *env, jclass clz, int8_tArray hrp_bytes, jobjectArray data_without_signature) {
26010         LDKu8slice hrp_bytes_ref;
26011         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
26012         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
26013         LDKCVec_u5Z data_without_signature_constr;
26014         data_without_signature_constr.datalen = (*env)->GetArrayLength(env, data_without_signature);
26015         if (data_without_signature_constr.datalen > 0)
26016                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKu5), "LDKCVec_u5Z Elements");
26017         else
26018                 data_without_signature_constr.data = NULL;
26019         int8_t* data_without_signature_vals = (*env)->GetByteArrayElements (env, data_without_signature, NULL);
26020         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
26021                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
26022                 
26023                 data_without_signature_constr.data[h] = (LDKu5){ ._0 = data_without_signature_conv_7 };
26024         }
26025         (*env)->ReleaseByteArrayElements(env, data_without_signature, data_without_signature_vals, 0);
26026         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
26027         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26028         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26029         CVec_u8Z_free(ret_var);
26030         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
26031         return ret_arr;
26032 }
26033
26034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26035         if (!ptr_is_owned(this_ptr)) return;
26036         void* this_ptr_ptr = untag_ptr(this_ptr);
26037         CHECK_ACCESS(this_ptr_ptr);
26038         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
26039         FREE(untag_ptr(this_ptr));
26040         Persister_free(this_ptr_conv);
26041 }
26042
26043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FutureCallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26044         if (!ptr_is_owned(this_ptr)) return;
26045         void* this_ptr_ptr = untag_ptr(this_ptr);
26046         CHECK_ACCESS(this_ptr_ptr);
26047         LDKFutureCallback this_ptr_conv = *(LDKFutureCallback*)(this_ptr_ptr);
26048         FREE(untag_ptr(this_ptr));
26049         FutureCallback_free(this_ptr_conv);
26050 }
26051
26052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26053         LDKFuture this_obj_conv;
26054         this_obj_conv.inner = untag_ptr(this_obj);
26055         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26057         Future_free(this_obj_conv);
26058 }
26059
26060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1register_1callback_1fn(JNIEnv *env, jclass clz, int64_t this_arg, int64_t callback) {
26061         LDKFuture this_arg_conv;
26062         this_arg_conv.inner = untag_ptr(this_arg);
26063         this_arg_conv.is_owned = ptr_is_owned(this_arg);
26064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
26065         this_arg_conv.is_owned = false;
26066         void* callback_ptr = untag_ptr(callback);
26067         CHECK_ACCESS(callback_ptr);
26068         LDKFutureCallback callback_conv = *(LDKFutureCallback*)(callback_ptr);
26069         if (callback_conv.free == LDKFutureCallback_JCalls_free) {
26070                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
26071                 LDKFutureCallback_JCalls_cloned(&callback_conv);
26072         }
26073         Future_register_callback_fn(&this_arg_conv, callback_conv);
26074 }
26075
26076 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26077         LDKLevel* orig_conv = (LDKLevel*)untag_ptr(orig);
26078         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
26079         return ret_conv;
26080 }
26081
26082 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
26083         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
26084         return ret_conv;
26085 }
26086
26087 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
26088         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
26089         return ret_conv;
26090 }
26091
26092 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
26093         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
26094         return ret_conv;
26095 }
26096
26097 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
26098         jclass ret_conv = LDKLevel_to_java(env, Level_info());
26099         return ret_conv;
26100 }
26101
26102 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
26103         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
26104         return ret_conv;
26105 }
26106
26107 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
26108         jclass ret_conv = LDKLevel_to_java(env, Level_error());
26109         return ret_conv;
26110 }
26111
26112 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26113         LDKLevel* a_conv = (LDKLevel*)untag_ptr(a);
26114         LDKLevel* b_conv = (LDKLevel*)untag_ptr(b);
26115         jboolean ret_conv = Level_eq(a_conv, b_conv);
26116         return ret_conv;
26117 }
26118
26119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
26120         LDKLevel* o_conv = (LDKLevel*)untag_ptr(o);
26121         int64_t ret_conv = Level_hash(o_conv);
26122         return ret_conv;
26123 }
26124
26125 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
26126         jclass ret_conv = LDKLevel_to_java(env, Level_max());
26127         return ret_conv;
26128 }
26129
26130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26131         LDKRecord this_obj_conv;
26132         this_obj_conv.inner = untag_ptr(this_obj);
26133         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26135         Record_free(this_obj_conv);
26136 }
26137
26138 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
26139         LDKRecord this_ptr_conv;
26140         this_ptr_conv.inner = untag_ptr(this_ptr);
26141         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26143         this_ptr_conv.is_owned = false;
26144         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
26145         return ret_conv;
26146 }
26147
26148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
26149         LDKRecord this_ptr_conv;
26150         this_ptr_conv.inner = untag_ptr(this_ptr);
26151         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26153         this_ptr_conv.is_owned = false;
26154         LDKLevel val_conv = LDKLevel_from_java(env, val);
26155         Record_set_level(&this_ptr_conv, val_conv);
26156 }
26157
26158 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
26159         LDKRecord this_ptr_conv;
26160         this_ptr_conv.inner = untag_ptr(this_ptr);
26161         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26163         this_ptr_conv.is_owned = false;
26164         LDKStr ret_str = Record_get_args(&this_ptr_conv);
26165         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26166         Str_free(ret_str);
26167         return ret_conv;
26168 }
26169
26170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
26171         LDKRecord this_ptr_conv;
26172         this_ptr_conv.inner = untag_ptr(this_ptr);
26173         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26175         this_ptr_conv.is_owned = false;
26176         LDKStr val_conv = java_to_owned_str(env, val);
26177         Record_set_args(&this_ptr_conv, val_conv);
26178 }
26179
26180 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
26181         LDKRecord this_ptr_conv;
26182         this_ptr_conv.inner = untag_ptr(this_ptr);
26183         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26185         this_ptr_conv.is_owned = false;
26186         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
26187         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26188         Str_free(ret_str);
26189         return ret_conv;
26190 }
26191
26192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
26193         LDKRecord this_ptr_conv;
26194         this_ptr_conv.inner = untag_ptr(this_ptr);
26195         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26197         this_ptr_conv.is_owned = false;
26198         LDKStr val_conv = java_to_owned_str(env, val);
26199         Record_set_module_path(&this_ptr_conv, val_conv);
26200 }
26201
26202 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
26203         LDKRecord this_ptr_conv;
26204         this_ptr_conv.inner = untag_ptr(this_ptr);
26205         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26207         this_ptr_conv.is_owned = false;
26208         LDKStr ret_str = Record_get_file(&this_ptr_conv);
26209         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
26210         Str_free(ret_str);
26211         return ret_conv;
26212 }
26213
26214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
26215         LDKRecord this_ptr_conv;
26216         this_ptr_conv.inner = untag_ptr(this_ptr);
26217         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26219         this_ptr_conv.is_owned = false;
26220         LDKStr val_conv = java_to_owned_str(env, val);
26221         Record_set_file(&this_ptr_conv, val_conv);
26222 }
26223
26224 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
26225         LDKRecord this_ptr_conv;
26226         this_ptr_conv.inner = untag_ptr(this_ptr);
26227         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26229         this_ptr_conv.is_owned = false;
26230         int32_t ret_conv = Record_get_line(&this_ptr_conv);
26231         return ret_conv;
26232 }
26233
26234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
26235         LDKRecord this_ptr_conv;
26236         this_ptr_conv.inner = untag_ptr(this_ptr);
26237         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26239         this_ptr_conv.is_owned = false;
26240         Record_set_line(&this_ptr_conv, val);
26241 }
26242
26243 static inline uint64_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
26244         LDKRecord ret_var = Record_clone(arg);
26245         int64_t ret_ref = 0;
26246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26247         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26248         return ret_ref;
26249 }
26250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26251         LDKRecord arg_conv;
26252         arg_conv.inner = untag_ptr(arg);
26253         arg_conv.is_owned = ptr_is_owned(arg);
26254         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26255         arg_conv.is_owned = false;
26256         int64_t ret_conv = Record_clone_ptr(&arg_conv);
26257         return ret_conv;
26258 }
26259
26260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26261         LDKRecord orig_conv;
26262         orig_conv.inner = untag_ptr(orig);
26263         orig_conv.is_owned = ptr_is_owned(orig);
26264         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26265         orig_conv.is_owned = false;
26266         LDKRecord ret_var = Record_clone(&orig_conv);
26267         int64_t ret_ref = 0;
26268         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26269         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26270         return ret_ref;
26271 }
26272
26273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26274         if (!ptr_is_owned(this_ptr)) return;
26275         void* this_ptr_ptr = untag_ptr(this_ptr);
26276         CHECK_ACCESS(this_ptr_ptr);
26277         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
26278         FREE(untag_ptr(this_ptr));
26279         Logger_free(this_ptr_conv);
26280 }
26281
26282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26283         LDKChannelHandshakeConfig this_obj_conv;
26284         this_obj_conv.inner = untag_ptr(this_obj);
26285         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26287         ChannelHandshakeConfig_free(this_obj_conv);
26288 }
26289
26290 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
26291         LDKChannelHandshakeConfig this_ptr_conv;
26292         this_ptr_conv.inner = untag_ptr(this_ptr);
26293         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26295         this_ptr_conv.is_owned = false;
26296         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
26297         return ret_conv;
26298 }
26299
26300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
26301         LDKChannelHandshakeConfig this_ptr_conv;
26302         this_ptr_conv.inner = untag_ptr(this_ptr);
26303         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26305         this_ptr_conv.is_owned = false;
26306         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
26307 }
26308
26309 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
26310         LDKChannelHandshakeConfig this_ptr_conv;
26311         this_ptr_conv.inner = untag_ptr(this_ptr);
26312         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26314         this_ptr_conv.is_owned = false;
26315         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
26316         return ret_conv;
26317 }
26318
26319 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) {
26320         LDKChannelHandshakeConfig this_ptr_conv;
26321         this_ptr_conv.inner = untag_ptr(this_ptr);
26322         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26324         this_ptr_conv.is_owned = false;
26325         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
26326 }
26327
26328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26329         LDKChannelHandshakeConfig this_ptr_conv;
26330         this_ptr_conv.inner = untag_ptr(this_ptr);
26331         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26333         this_ptr_conv.is_owned = false;
26334         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
26335         return ret_conv;
26336 }
26337
26338 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) {
26339         LDKChannelHandshakeConfig this_ptr_conv;
26340         this_ptr_conv.inner = untag_ptr(this_ptr);
26341         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26343         this_ptr_conv.is_owned = false;
26344         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
26345 }
26346
26347 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1max_1inbound_1htlc_1value_1in_1flight_1percent_1of_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
26348         LDKChannelHandshakeConfig this_ptr_conv;
26349         this_ptr_conv.inner = untag_ptr(this_ptr);
26350         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26352         this_ptr_conv.is_owned = false;
26353         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
26354         return ret_conv;
26355 }
26356
26357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1max_1inbound_1htlc_1value_1in_1flight_1percent_1of_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
26358         LDKChannelHandshakeConfig this_ptr_conv;
26359         this_ptr_conv.inner = untag_ptr(this_ptr);
26360         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26362         this_ptr_conv.is_owned = false;
26363         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
26364 }
26365
26366 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr) {
26367         LDKChannelHandshakeConfig this_ptr_conv;
26368         this_ptr_conv.inner = untag_ptr(this_ptr);
26369         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26371         this_ptr_conv.is_owned = false;
26372         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
26373         return ret_conv;
26374 }
26375
26376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26377         LDKChannelHandshakeConfig this_ptr_conv;
26378         this_ptr_conv.inner = untag_ptr(this_ptr);
26379         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26381         this_ptr_conv.is_owned = false;
26382         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
26383 }
26384
26385 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
26386         LDKChannelHandshakeConfig this_ptr_conv;
26387         this_ptr_conv.inner = untag_ptr(this_ptr);
26388         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26390         this_ptr_conv.is_owned = false;
26391         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
26392         return ret_conv;
26393 }
26394
26395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26396         LDKChannelHandshakeConfig this_ptr_conv;
26397         this_ptr_conv.inner = untag_ptr(this_ptr);
26398         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26400         this_ptr_conv.is_owned = false;
26401         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
26402 }
26403
26404 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
26405         LDKChannelHandshakeConfig this_ptr_conv;
26406         this_ptr_conv.inner = untag_ptr(this_ptr);
26407         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26409         this_ptr_conv.is_owned = false;
26410         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
26411         return ret_conv;
26412 }
26413
26414 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26415         LDKChannelHandshakeConfig this_ptr_conv;
26416         this_ptr_conv.inner = untag_ptr(this_ptr);
26417         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26419         this_ptr_conv.is_owned = false;
26420         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
26421 }
26422
26423 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1their_1channel_1reserve_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
26424         LDKChannelHandshakeConfig this_ptr_conv;
26425         this_ptr_conv.inner = untag_ptr(this_ptr);
26426         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26428         this_ptr_conv.is_owned = false;
26429         int32_t ret_conv = ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(&this_ptr_conv);
26430         return ret_conv;
26431 }
26432
26433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1their_1channel_1reserve_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
26434         LDKChannelHandshakeConfig this_ptr_conv;
26435         this_ptr_conv.inner = untag_ptr(this_ptr);
26436         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26438         this_ptr_conv.is_owned = false;
26439         ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(&this_ptr_conv, val);
26440 }
26441
26442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1new(JNIEnv *env, jclass clz, int32_t minimum_depth_arg, int16_t our_to_self_delay_arg, int64_t our_htlc_minimum_msat_arg, int8_t max_inbound_htlc_value_in_flight_percent_of_channel_arg, jboolean negotiate_scid_privacy_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int32_t their_channel_reserve_proportional_millionths_arg) {
26443         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg, max_inbound_htlc_value_in_flight_percent_of_channel_arg, negotiate_scid_privacy_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, their_channel_reserve_proportional_millionths_arg);
26444         int64_t ret_ref = 0;
26445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26446         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26447         return ret_ref;
26448 }
26449
26450 static inline uint64_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
26451         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
26452         int64_t ret_ref = 0;
26453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26454         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26455         return ret_ref;
26456 }
26457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26458         LDKChannelHandshakeConfig arg_conv;
26459         arg_conv.inner = untag_ptr(arg);
26460         arg_conv.is_owned = ptr_is_owned(arg);
26461         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26462         arg_conv.is_owned = false;
26463         int64_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
26464         return ret_conv;
26465 }
26466
26467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26468         LDKChannelHandshakeConfig orig_conv;
26469         orig_conv.inner = untag_ptr(orig);
26470         orig_conv.is_owned = ptr_is_owned(orig);
26471         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26472         orig_conv.is_owned = false;
26473         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
26474         int64_t ret_ref = 0;
26475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26476         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26477         return ret_ref;
26478 }
26479
26480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
26481         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
26482         int64_t ret_ref = 0;
26483         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26484         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26485         return ret_ref;
26486 }
26487
26488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26489         LDKChannelHandshakeLimits this_obj_conv;
26490         this_obj_conv.inner = untag_ptr(this_obj);
26491         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26493         ChannelHandshakeLimits_free(this_obj_conv);
26494 }
26495
26496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26497         LDKChannelHandshakeLimits this_ptr_conv;
26498         this_ptr_conv.inner = untag_ptr(this_ptr);
26499         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26501         this_ptr_conv.is_owned = false;
26502         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
26503         return ret_conv;
26504 }
26505
26506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26507         LDKChannelHandshakeLimits this_ptr_conv;
26508         this_ptr_conv.inner = untag_ptr(this_ptr);
26509         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26511         this_ptr_conv.is_owned = false;
26512         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
26513 }
26514
26515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26516         LDKChannelHandshakeLimits this_ptr_conv;
26517         this_ptr_conv.inner = untag_ptr(this_ptr);
26518         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26520         this_ptr_conv.is_owned = false;
26521         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
26522         return ret_conv;
26523 }
26524
26525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26526         LDKChannelHandshakeLimits this_ptr_conv;
26527         this_ptr_conv.inner = untag_ptr(this_ptr);
26528         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26529         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26530         this_ptr_conv.is_owned = false;
26531         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
26532 }
26533
26534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26535         LDKChannelHandshakeLimits this_ptr_conv;
26536         this_ptr_conv.inner = untag_ptr(this_ptr);
26537         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26539         this_ptr_conv.is_owned = false;
26540         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
26541         return ret_conv;
26542 }
26543
26544 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) {
26545         LDKChannelHandshakeLimits this_ptr_conv;
26546         this_ptr_conv.inner = untag_ptr(this_ptr);
26547         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26549         this_ptr_conv.is_owned = false;
26550         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
26551 }
26552
26553 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) {
26554         LDKChannelHandshakeLimits this_ptr_conv;
26555         this_ptr_conv.inner = untag_ptr(this_ptr);
26556         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26558         this_ptr_conv.is_owned = false;
26559         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
26560         return ret_conv;
26561 }
26562
26563 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) {
26564         LDKChannelHandshakeLimits this_ptr_conv;
26565         this_ptr_conv.inner = untag_ptr(this_ptr);
26566         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26568         this_ptr_conv.is_owned = false;
26569         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
26570 }
26571
26572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26573         LDKChannelHandshakeLimits this_ptr_conv;
26574         this_ptr_conv.inner = untag_ptr(this_ptr);
26575         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26577         this_ptr_conv.is_owned = false;
26578         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
26579         return ret_conv;
26580 }
26581
26582 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) {
26583         LDKChannelHandshakeLimits this_ptr_conv;
26584         this_ptr_conv.inner = untag_ptr(this_ptr);
26585         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26587         this_ptr_conv.is_owned = false;
26588         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
26589 }
26590
26591 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
26592         LDKChannelHandshakeLimits this_ptr_conv;
26593         this_ptr_conv.inner = untag_ptr(this_ptr);
26594         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26596         this_ptr_conv.is_owned = false;
26597         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
26598         return ret_conv;
26599 }
26600
26601 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) {
26602         LDKChannelHandshakeLimits this_ptr_conv;
26603         this_ptr_conv.inner = untag_ptr(this_ptr);
26604         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26606         this_ptr_conv.is_owned = false;
26607         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
26608 }
26609
26610 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
26611         LDKChannelHandshakeLimits this_ptr_conv;
26612         this_ptr_conv.inner = untag_ptr(this_ptr);
26613         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26615         this_ptr_conv.is_owned = false;
26616         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
26617         return ret_conv;
26618 }
26619
26620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
26621         LDKChannelHandshakeLimits this_ptr_conv;
26622         this_ptr_conv.inner = untag_ptr(this_ptr);
26623         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26625         this_ptr_conv.is_owned = false;
26626         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
26627 }
26628
26629 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr) {
26630         LDKChannelHandshakeLimits this_ptr_conv;
26631         this_ptr_conv.inner = untag_ptr(this_ptr);
26632         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26634         this_ptr_conv.is_owned = false;
26635         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
26636         return ret_conv;
26637 }
26638
26639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26640         LDKChannelHandshakeLimits this_ptr_conv;
26641         this_ptr_conv.inner = untag_ptr(this_ptr);
26642         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26644         this_ptr_conv.is_owned = false;
26645         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
26646 }
26647
26648 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
26649         LDKChannelHandshakeLimits this_ptr_conv;
26650         this_ptr_conv.inner = untag_ptr(this_ptr);
26651         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26653         this_ptr_conv.is_owned = false;
26654         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
26655         return ret_conv;
26656 }
26657
26658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
26659         LDKChannelHandshakeLimits this_ptr_conv;
26660         this_ptr_conv.inner = untag_ptr(this_ptr);
26661         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26663         this_ptr_conv.is_owned = false;
26664         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
26665 }
26666
26667 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
26668         LDKChannelHandshakeLimits this_ptr_conv;
26669         this_ptr_conv.inner = untag_ptr(this_ptr);
26670         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26672         this_ptr_conv.is_owned = false;
26673         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
26674         return ret_conv;
26675 }
26676
26677 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) {
26678         LDKChannelHandshakeLimits this_ptr_conv;
26679         this_ptr_conv.inner = untag_ptr(this_ptr);
26680         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26682         this_ptr_conv.is_owned = false;
26683         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
26684 }
26685
26686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1new(JNIEnv *env, jclass clz, int64_t min_funding_satoshis_arg, int64_t max_funding_satoshis_arg, int64_t max_htlc_minimum_msat_arg, int64_t min_max_htlc_value_in_flight_msat_arg, int64_t max_channel_reserve_satoshis_arg, int16_t min_max_accepted_htlcs_arg, int32_t max_minimum_depth_arg, jboolean trust_own_funding_0conf_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
26687         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_new(min_funding_satoshis_arg, max_funding_satoshis_arg, max_htlc_minimum_msat_arg, min_max_htlc_value_in_flight_msat_arg, max_channel_reserve_satoshis_arg, min_max_accepted_htlcs_arg, max_minimum_depth_arg, trust_own_funding_0conf_arg, force_announced_channel_preference_arg, their_to_self_delay_arg);
26688         int64_t ret_ref = 0;
26689         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26690         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26691         return ret_ref;
26692 }
26693
26694 static inline uint64_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
26695         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
26696         int64_t ret_ref = 0;
26697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26698         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26699         return ret_ref;
26700 }
26701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26702         LDKChannelHandshakeLimits arg_conv;
26703         arg_conv.inner = untag_ptr(arg);
26704         arg_conv.is_owned = ptr_is_owned(arg);
26705         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26706         arg_conv.is_owned = false;
26707         int64_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
26708         return ret_conv;
26709 }
26710
26711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26712         LDKChannelHandshakeLimits orig_conv;
26713         orig_conv.inner = untag_ptr(orig);
26714         orig_conv.is_owned = ptr_is_owned(orig);
26715         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26716         orig_conv.is_owned = false;
26717         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
26718         int64_t ret_ref = 0;
26719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26720         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26721         return ret_ref;
26722 }
26723
26724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
26725         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
26726         int64_t ret_ref = 0;
26727         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26728         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26729         return ret_ref;
26730 }
26731
26732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26733         LDKChannelConfig this_obj_conv;
26734         this_obj_conv.inner = untag_ptr(this_obj);
26735         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26737         ChannelConfig_free(this_obj_conv);
26738 }
26739
26740 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
26741         LDKChannelConfig this_ptr_conv;
26742         this_ptr_conv.inner = untag_ptr(this_ptr);
26743         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26745         this_ptr_conv.is_owned = false;
26746         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
26747         return ret_conv;
26748 }
26749
26750 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) {
26751         LDKChannelConfig this_ptr_conv;
26752         this_ptr_conv.inner = untag_ptr(this_ptr);
26753         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26755         this_ptr_conv.is_owned = false;
26756         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
26757 }
26758
26759 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26760         LDKChannelConfig this_ptr_conv;
26761         this_ptr_conv.inner = untag_ptr(this_ptr);
26762         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26764         this_ptr_conv.is_owned = false;
26765         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
26766         return ret_conv;
26767 }
26768
26769 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) {
26770         LDKChannelConfig this_ptr_conv;
26771         this_ptr_conv.inner = untag_ptr(this_ptr);
26772         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26774         this_ptr_conv.is_owned = false;
26775         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
26776 }
26777
26778 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
26779         LDKChannelConfig this_ptr_conv;
26780         this_ptr_conv.inner = untag_ptr(this_ptr);
26781         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26783         this_ptr_conv.is_owned = false;
26784         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
26785         return ret_conv;
26786 }
26787
26788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26789         LDKChannelConfig this_ptr_conv;
26790         this_ptr_conv.inner = untag_ptr(this_ptr);
26791         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26793         this_ptr_conv.is_owned = false;
26794         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
26795 }
26796
26797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26798         LDKChannelConfig this_ptr_conv;
26799         this_ptr_conv.inner = untag_ptr(this_ptr);
26800         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26802         this_ptr_conv.is_owned = false;
26803         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
26804         return ret_conv;
26805 }
26806
26807 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) {
26808         LDKChannelConfig this_ptr_conv;
26809         this_ptr_conv.inner = untag_ptr(this_ptr);
26810         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26812         this_ptr_conv.is_owned = false;
26813         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
26814 }
26815
26816 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) {
26817         LDKChannelConfig this_ptr_conv;
26818         this_ptr_conv.inner = untag_ptr(this_ptr);
26819         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26821         this_ptr_conv.is_owned = false;
26822         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
26823         return ret_conv;
26824 }
26825
26826 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) {
26827         LDKChannelConfig this_ptr_conv;
26828         this_ptr_conv.inner = untag_ptr(this_ptr);
26829         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26831         this_ptr_conv.is_owned = false;
26832         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
26833 }
26834
26835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1new(JNIEnv *env, jclass clz, int32_t forwarding_fee_proportional_millionths_arg, int32_t forwarding_fee_base_msat_arg, int16_t cltv_expiry_delta_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
26836         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
26837         int64_t ret_ref = 0;
26838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26839         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26840         return ret_ref;
26841 }
26842
26843 static inline uint64_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
26844         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
26845         int64_t ret_ref = 0;
26846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26847         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26848         return ret_ref;
26849 }
26850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26851         LDKChannelConfig arg_conv;
26852         arg_conv.inner = untag_ptr(arg);
26853         arg_conv.is_owned = ptr_is_owned(arg);
26854         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26855         arg_conv.is_owned = false;
26856         int64_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
26857         return ret_conv;
26858 }
26859
26860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26861         LDKChannelConfig orig_conv;
26862         orig_conv.inner = untag_ptr(orig);
26863         orig_conv.is_owned = ptr_is_owned(orig);
26864         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26865         orig_conv.is_owned = false;
26866         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
26867         int64_t ret_ref = 0;
26868         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26869         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26870         return ret_ref;
26871 }
26872
26873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
26874         LDKChannelConfig ret_var = ChannelConfig_default();
26875         int64_t ret_ref = 0;
26876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26877         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26878         return ret_ref;
26879 }
26880
26881 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
26882         LDKChannelConfig obj_conv;
26883         obj_conv.inner = untag_ptr(obj);
26884         obj_conv.is_owned = ptr_is_owned(obj);
26885         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
26886         obj_conv.is_owned = false;
26887         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
26888         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26889         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26890         CVec_u8Z_free(ret_var);
26891         return ret_arr;
26892 }
26893
26894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26895         LDKu8slice ser_ref;
26896         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26897         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26898         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
26899         *ret_conv = ChannelConfig_read(ser_ref);
26900         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26901         return tag_ptr(ret_conv, true);
26902 }
26903
26904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26905         LDKUserConfig this_obj_conv;
26906         this_obj_conv.inner = untag_ptr(this_obj);
26907         this_obj_conv.is_owned = ptr_is_owned(this_obj);
26908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26909         UserConfig_free(this_obj_conv);
26910 }
26911
26912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
26913         LDKUserConfig this_ptr_conv;
26914         this_ptr_conv.inner = untag_ptr(this_ptr);
26915         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26917         this_ptr_conv.is_owned = false;
26918         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
26919         int64_t ret_ref = 0;
26920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26921         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26922         return ret_ref;
26923 }
26924
26925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26926         LDKUserConfig this_ptr_conv;
26927         this_ptr_conv.inner = untag_ptr(this_ptr);
26928         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26930         this_ptr_conv.is_owned = false;
26931         LDKChannelHandshakeConfig val_conv;
26932         val_conv.inner = untag_ptr(val);
26933         val_conv.is_owned = ptr_is_owned(val);
26934         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26935         val_conv = ChannelHandshakeConfig_clone(&val_conv);
26936         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
26937 }
26938
26939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
26940         LDKUserConfig this_ptr_conv;
26941         this_ptr_conv.inner = untag_ptr(this_ptr);
26942         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26944         this_ptr_conv.is_owned = false;
26945         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
26946         int64_t ret_ref = 0;
26947         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26948         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26949         return ret_ref;
26950 }
26951
26952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26953         LDKUserConfig this_ptr_conv;
26954         this_ptr_conv.inner = untag_ptr(this_ptr);
26955         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26957         this_ptr_conv.is_owned = false;
26958         LDKChannelHandshakeLimits val_conv;
26959         val_conv.inner = untag_ptr(val);
26960         val_conv.is_owned = ptr_is_owned(val);
26961         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26962         val_conv = ChannelHandshakeLimits_clone(&val_conv);
26963         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
26964 }
26965
26966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
26967         LDKUserConfig this_ptr_conv;
26968         this_ptr_conv.inner = untag_ptr(this_ptr);
26969         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26971         this_ptr_conv.is_owned = false;
26972         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
26973         int64_t ret_ref = 0;
26974         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26975         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
26976         return ret_ref;
26977 }
26978
26979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26980         LDKUserConfig this_ptr_conv;
26981         this_ptr_conv.inner = untag_ptr(this_ptr);
26982         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26984         this_ptr_conv.is_owned = false;
26985         LDKChannelConfig val_conv;
26986         val_conv.inner = untag_ptr(val);
26987         val_conv.is_owned = ptr_is_owned(val);
26988         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
26989         val_conv = ChannelConfig_clone(&val_conv);
26990         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
26991 }
26992
26993 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
26994         LDKUserConfig this_ptr_conv;
26995         this_ptr_conv.inner = untag_ptr(this_ptr);
26996         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
26997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26998         this_ptr_conv.is_owned = false;
26999         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
27000         return ret_conv;
27001 }
27002
27003 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) {
27004         LDKUserConfig this_ptr_conv;
27005         this_ptr_conv.inner = untag_ptr(this_ptr);
27006         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27008         this_ptr_conv.is_owned = false;
27009         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
27010 }
27011
27012 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
27013         LDKUserConfig this_ptr_conv;
27014         this_ptr_conv.inner = untag_ptr(this_ptr);
27015         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27017         this_ptr_conv.is_owned = false;
27018         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
27019         return ret_conv;
27020 }
27021
27022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27023         LDKUserConfig this_ptr_conv;
27024         this_ptr_conv.inner = untag_ptr(this_ptr);
27025         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27027         this_ptr_conv.is_owned = false;
27028         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
27029 }
27030
27031 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
27032         LDKUserConfig this_ptr_conv;
27033         this_ptr_conv.inner = untag_ptr(this_ptr);
27034         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27036         this_ptr_conv.is_owned = false;
27037         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
27038         return ret_conv;
27039 }
27040
27041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27042         LDKUserConfig this_ptr_conv;
27043         this_ptr_conv.inner = untag_ptr(this_ptr);
27044         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27046         this_ptr_conv.is_owned = false;
27047         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
27048 }
27049
27050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env, jclass clz, int64_t channel_handshake_config_arg, int64_t channel_handshake_limits_arg, int64_t channel_config_arg, jboolean accept_forwards_to_priv_channels_arg, jboolean accept_inbound_channels_arg, jboolean manually_accept_inbound_channels_arg) {
27051         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
27052         channel_handshake_config_arg_conv.inner = untag_ptr(channel_handshake_config_arg);
27053         channel_handshake_config_arg_conv.is_owned = ptr_is_owned(channel_handshake_config_arg);
27054         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
27055         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
27056         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
27057         channel_handshake_limits_arg_conv.inner = untag_ptr(channel_handshake_limits_arg);
27058         channel_handshake_limits_arg_conv.is_owned = ptr_is_owned(channel_handshake_limits_arg);
27059         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
27060         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
27061         LDKChannelConfig channel_config_arg_conv;
27062         channel_config_arg_conv.inner = untag_ptr(channel_config_arg);
27063         channel_config_arg_conv.is_owned = ptr_is_owned(channel_config_arg);
27064         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
27065         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
27066         LDKUserConfig ret_var = UserConfig_new(channel_handshake_config_arg_conv, channel_handshake_limits_arg_conv, channel_config_arg_conv, accept_forwards_to_priv_channels_arg, accept_inbound_channels_arg, manually_accept_inbound_channels_arg);
27067         int64_t ret_ref = 0;
27068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27069         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27070         return ret_ref;
27071 }
27072
27073 static inline uint64_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
27074         LDKUserConfig ret_var = UserConfig_clone(arg);
27075         int64_t ret_ref = 0;
27076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27077         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27078         return ret_ref;
27079 }
27080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27081         LDKUserConfig arg_conv;
27082         arg_conv.inner = untag_ptr(arg);
27083         arg_conv.is_owned = ptr_is_owned(arg);
27084         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27085         arg_conv.is_owned = false;
27086         int64_t ret_conv = UserConfig_clone_ptr(&arg_conv);
27087         return ret_conv;
27088 }
27089
27090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27091         LDKUserConfig orig_conv;
27092         orig_conv.inner = untag_ptr(orig);
27093         orig_conv.is_owned = ptr_is_owned(orig);
27094         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27095         orig_conv.is_owned = false;
27096         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
27097         int64_t ret_ref = 0;
27098         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27099         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27100         return ret_ref;
27101 }
27102
27103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
27104         LDKUserConfig ret_var = UserConfig_default();
27105         int64_t ret_ref = 0;
27106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27107         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27108         return ret_ref;
27109 }
27110
27111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27112         LDKBestBlock this_obj_conv;
27113         this_obj_conv.inner = untag_ptr(this_obj);
27114         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27116         BestBlock_free(this_obj_conv);
27117 }
27118
27119 static inline uint64_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
27120         LDKBestBlock ret_var = BestBlock_clone(arg);
27121         int64_t ret_ref = 0;
27122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27123         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27124         return ret_ref;
27125 }
27126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27127         LDKBestBlock arg_conv;
27128         arg_conv.inner = untag_ptr(arg);
27129         arg_conv.is_owned = ptr_is_owned(arg);
27130         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27131         arg_conv.is_owned = false;
27132         int64_t ret_conv = BestBlock_clone_ptr(&arg_conv);
27133         return ret_conv;
27134 }
27135
27136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27137         LDKBestBlock orig_conv;
27138         orig_conv.inner = untag_ptr(orig);
27139         orig_conv.is_owned = ptr_is_owned(orig);
27140         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27141         orig_conv.is_owned = false;
27142         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
27143         int64_t ret_ref = 0;
27144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27145         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27146         return ret_ref;
27147 }
27148
27149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
27150         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
27151         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
27152         int64_t ret_ref = 0;
27153         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27154         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27155         return ret_ref;
27156 }
27157
27158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
27159         LDKThirtyTwoBytes block_hash_ref;
27160         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
27161         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
27162         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
27163         int64_t ret_ref = 0;
27164         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27165         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27166         return ret_ref;
27167 }
27168
27169 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
27170         LDKBestBlock this_arg_conv;
27171         this_arg_conv.inner = untag_ptr(this_arg);
27172         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27174         this_arg_conv.is_owned = false;
27175         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27176         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
27177         return ret_arr;
27178 }
27179
27180 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
27181         LDKBestBlock this_arg_conv;
27182         this_arg_conv.inner = untag_ptr(this_arg);
27183         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27185         this_arg_conv.is_owned = false;
27186         int32_t ret_conv = BestBlock_height(&this_arg_conv);
27187         return ret_conv;
27188 }
27189
27190 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27191         LDKAccessError* orig_conv = (LDKAccessError*)untag_ptr(orig);
27192         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
27193         return ret_conv;
27194 }
27195
27196 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
27197         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
27198         return ret_conv;
27199 }
27200
27201 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
27202         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
27203         return ret_conv;
27204 }
27205
27206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27207         if (!ptr_is_owned(this_ptr)) return;
27208         void* this_ptr_ptr = untag_ptr(this_ptr);
27209         CHECK_ACCESS(this_ptr_ptr);
27210         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
27211         FREE(untag_ptr(this_ptr));
27212         Access_free(this_ptr_conv);
27213 }
27214
27215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27216         if (!ptr_is_owned(this_ptr)) return;
27217         void* this_ptr_ptr = untag_ptr(this_ptr);
27218         CHECK_ACCESS(this_ptr_ptr);
27219         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
27220         FREE(untag_ptr(this_ptr));
27221         Listen_free(this_ptr_conv);
27222 }
27223
27224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27225         if (!ptr_is_owned(this_ptr)) return;
27226         void* this_ptr_ptr = untag_ptr(this_ptr);
27227         CHECK_ACCESS(this_ptr_ptr);
27228         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
27229         FREE(untag_ptr(this_ptr));
27230         Confirm_free(this_ptr_conv);
27231 }
27232
27233 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27234         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)untag_ptr(orig);
27235         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
27236         return ret_conv;
27237 }
27238
27239 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
27240         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
27241         return ret_conv;
27242 }
27243
27244 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
27245         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
27246         return ret_conv;
27247 }
27248
27249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27250         if (!ptr_is_owned(this_ptr)) return;
27251         void* this_ptr_ptr = untag_ptr(this_ptr);
27252         CHECK_ACCESS(this_ptr_ptr);
27253         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
27254         FREE(untag_ptr(this_ptr));
27255         Watch_free(this_ptr_conv);
27256 }
27257
27258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27259         if (!ptr_is_owned(this_ptr)) return;
27260         void* this_ptr_ptr = untag_ptr(this_ptr);
27261         CHECK_ACCESS(this_ptr_ptr);
27262         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
27263         FREE(untag_ptr(this_ptr));
27264         Filter_free(this_ptr_conv);
27265 }
27266
27267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27268         LDKWatchedOutput this_obj_conv;
27269         this_obj_conv.inner = untag_ptr(this_obj);
27270         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27272         WatchedOutput_free(this_obj_conv);
27273 }
27274
27275 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
27276         LDKWatchedOutput this_ptr_conv;
27277         this_ptr_conv.inner = untag_ptr(this_ptr);
27278         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27280         this_ptr_conv.is_owned = false;
27281         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27282         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
27283         return ret_arr;
27284 }
27285
27286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27287         LDKWatchedOutput this_ptr_conv;
27288         this_ptr_conv.inner = untag_ptr(this_ptr);
27289         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27291         this_ptr_conv.is_owned = false;
27292         LDKThirtyTwoBytes val_ref;
27293         CHECK((*env)->GetArrayLength(env, val) == 32);
27294         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27295         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
27296 }
27297
27298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
27299         LDKWatchedOutput this_ptr_conv;
27300         this_ptr_conv.inner = untag_ptr(this_ptr);
27301         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27303         this_ptr_conv.is_owned = false;
27304         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
27305         int64_t ret_ref = 0;
27306         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27307         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27308         return ret_ref;
27309 }
27310
27311 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27312         LDKWatchedOutput this_ptr_conv;
27313         this_ptr_conv.inner = untag_ptr(this_ptr);
27314         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27316         this_ptr_conv.is_owned = false;
27317         LDKOutPoint val_conv;
27318         val_conv.inner = untag_ptr(val);
27319         val_conv.is_owned = ptr_is_owned(val);
27320         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27321         val_conv = OutPoint_clone(&val_conv);
27322         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
27323 }
27324
27325 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
27326         LDKWatchedOutput this_ptr_conv;
27327         this_ptr_conv.inner = untag_ptr(this_ptr);
27328         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27330         this_ptr_conv.is_owned = false;
27331         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
27332         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27333         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27334         return ret_arr;
27335 }
27336
27337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27338         LDKWatchedOutput this_ptr_conv;
27339         this_ptr_conv.inner = untag_ptr(this_ptr);
27340         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27342         this_ptr_conv.is_owned = false;
27343         LDKCVec_u8Z val_ref;
27344         val_ref.datalen = (*env)->GetArrayLength(env, val);
27345         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
27346         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
27347         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
27348 }
27349
27350 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) {
27351         LDKThirtyTwoBytes block_hash_arg_ref;
27352         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
27353         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
27354         LDKOutPoint outpoint_arg_conv;
27355         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
27356         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
27357         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
27358         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
27359         LDKCVec_u8Z script_pubkey_arg_ref;
27360         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
27361         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
27362         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
27363         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
27364         int64_t ret_ref = 0;
27365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27366         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27367         return ret_ref;
27368 }
27369
27370 static inline uint64_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
27371         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
27372         int64_t ret_ref = 0;
27373         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27374         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27375         return ret_ref;
27376 }
27377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27378         LDKWatchedOutput arg_conv;
27379         arg_conv.inner = untag_ptr(arg);
27380         arg_conv.is_owned = ptr_is_owned(arg);
27381         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27382         arg_conv.is_owned = false;
27383         int64_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
27384         return ret_conv;
27385 }
27386
27387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27388         LDKWatchedOutput orig_conv;
27389         orig_conv.inner = untag_ptr(orig);
27390         orig_conv.is_owned = ptr_is_owned(orig);
27391         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27392         orig_conv.is_owned = false;
27393         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
27394         int64_t ret_ref = 0;
27395         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27396         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27397         return ret_ref;
27398 }
27399
27400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
27401         LDKWatchedOutput o_conv;
27402         o_conv.inner = untag_ptr(o);
27403         o_conv.is_owned = ptr_is_owned(o);
27404         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
27405         o_conv.is_owned = false;
27406         int64_t ret_conv = WatchedOutput_hash(&o_conv);
27407         return ret_conv;
27408 }
27409
27410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27411         if (!ptr_is_owned(this_ptr)) return;
27412         void* this_ptr_ptr = untag_ptr(this_ptr);
27413         CHECK_ACCESS(this_ptr_ptr);
27414         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
27415         FREE(untag_ptr(this_ptr));
27416         BroadcasterInterface_free(this_ptr_conv);
27417 }
27418
27419 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27420         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)untag_ptr(orig);
27421         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
27422         return ret_conv;
27423 }
27424
27425 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
27426         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
27427         return ret_conv;
27428 }
27429
27430 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
27431         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
27432         return ret_conv;
27433 }
27434
27435 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
27436         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
27437         return ret_conv;
27438 }
27439
27440 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27441         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)untag_ptr(a);
27442         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)untag_ptr(b);
27443         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
27444         return ret_conv;
27445 }
27446
27447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27448         if (!ptr_is_owned(this_ptr)) return;
27449         void* this_ptr_ptr = untag_ptr(this_ptr);
27450         CHECK_ACCESS(this_ptr_ptr);
27451         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
27452         FREE(untag_ptr(this_ptr));
27453         FeeEstimator_free(this_ptr_conv);
27454 }
27455
27456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27457         LDKMonitorUpdateId this_obj_conv;
27458         this_obj_conv.inner = untag_ptr(this_obj);
27459         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27461         MonitorUpdateId_free(this_obj_conv);
27462 }
27463
27464 static inline uint64_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
27465         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
27466         int64_t ret_ref = 0;
27467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27468         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27469         return ret_ref;
27470 }
27471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27472         LDKMonitorUpdateId arg_conv;
27473         arg_conv.inner = untag_ptr(arg);
27474         arg_conv.is_owned = ptr_is_owned(arg);
27475         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27476         arg_conv.is_owned = false;
27477         int64_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
27478         return ret_conv;
27479 }
27480
27481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27482         LDKMonitorUpdateId orig_conv;
27483         orig_conv.inner = untag_ptr(orig);
27484         orig_conv.is_owned = ptr_is_owned(orig);
27485         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27486         orig_conv.is_owned = false;
27487         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
27488         int64_t ret_ref = 0;
27489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27490         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27491         return ret_ref;
27492 }
27493
27494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
27495         LDKMonitorUpdateId o_conv;
27496         o_conv.inner = untag_ptr(o);
27497         o_conv.is_owned = ptr_is_owned(o);
27498         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
27499         o_conv.is_owned = false;
27500         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
27501         return ret_conv;
27502 }
27503
27504 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27505         LDKMonitorUpdateId a_conv;
27506         a_conv.inner = untag_ptr(a);
27507         a_conv.is_owned = ptr_is_owned(a);
27508         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27509         a_conv.is_owned = false;
27510         LDKMonitorUpdateId b_conv;
27511         b_conv.inner = untag_ptr(b);
27512         b_conv.is_owned = ptr_is_owned(b);
27513         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27514         b_conv.is_owned = false;
27515         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
27516         return ret_conv;
27517 }
27518
27519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27520         if (!ptr_is_owned(this_ptr)) return;
27521         void* this_ptr_ptr = untag_ptr(this_ptr);
27522         CHECK_ACCESS(this_ptr_ptr);
27523         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
27524         FREE(untag_ptr(this_ptr));
27525         Persist_free(this_ptr_conv);
27526 }
27527
27528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27529         LDKLockedChannelMonitor this_obj_conv;
27530         this_obj_conv.inner = untag_ptr(this_obj);
27531         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27533         LockedChannelMonitor_free(this_obj_conv);
27534 }
27535
27536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27537         LDKChainMonitor this_obj_conv;
27538         this_obj_conv.inner = untag_ptr(this_obj);
27539         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27541         ChainMonitor_free(this_obj_conv);
27542 }
27543
27544 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) {
27545         void* chain_source_ptr = untag_ptr(chain_source);
27546         CHECK_ACCESS(chain_source_ptr);
27547         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
27548         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
27549         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
27550                 // Manually implement clone for Java trait instances
27551                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
27552                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27553                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
27554                 }
27555         }
27556         void* broadcaster_ptr = untag_ptr(broadcaster);
27557         CHECK_ACCESS(broadcaster_ptr);
27558         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
27559         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
27560                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27561                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
27562         }
27563         void* logger_ptr = untag_ptr(logger);
27564         CHECK_ACCESS(logger_ptr);
27565         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
27566         if (logger_conv.free == LDKLogger_JCalls_free) {
27567                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27568                 LDKLogger_JCalls_cloned(&logger_conv);
27569         }
27570         void* feeest_ptr = untag_ptr(feeest);
27571         CHECK_ACCESS(feeest_ptr);
27572         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
27573         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
27574                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27575                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
27576         }
27577         void* persister_ptr = untag_ptr(persister);
27578         CHECK_ACCESS(persister_ptr);
27579         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
27580         if (persister_conv.free == LDKPersist_JCalls_free) {
27581                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27582                 LDKPersist_JCalls_cloned(&persister_conv);
27583         }
27584         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
27585         int64_t ret_ref = 0;
27586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27587         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27588         return ret_ref;
27589 }
27590
27591 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) {
27592         LDKChainMonitor this_arg_conv;
27593         this_arg_conv.inner = untag_ptr(this_arg);
27594         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27596         this_arg_conv.is_owned = false;
27597         LDKCVec_ChannelDetailsZ ignored_channels_constr;
27598         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
27599         if (ignored_channels_constr.datalen > 0)
27600                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
27601         else
27602                 ignored_channels_constr.data = NULL;
27603         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
27604         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
27605                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
27606                 LDKChannelDetails ignored_channels_conv_16_conv;
27607                 ignored_channels_conv_16_conv.inner = untag_ptr(ignored_channels_conv_16);
27608                 ignored_channels_conv_16_conv.is_owned = ptr_is_owned(ignored_channels_conv_16);
27609                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
27610                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
27611                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
27612         }
27613         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
27614         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
27615         int64_tArray ret_arr = NULL;
27616         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27617         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27618         for (size_t j = 0; j < ret_var.datalen; j++) {
27619                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27620                 *ret_conv_9_copy = ret_var.data[j];
27621                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
27622                 ret_arr_ptr[j] = ret_conv_9_ref;
27623         }
27624         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27625         FREE(ret_var.data);
27626         return ret_arr;
27627 }
27628
27629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
27630         LDKChainMonitor this_arg_conv;
27631         this_arg_conv.inner = untag_ptr(this_arg);
27632         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27634         this_arg_conv.is_owned = false;
27635         LDKOutPoint funding_txo_conv;
27636         funding_txo_conv.inner = untag_ptr(funding_txo);
27637         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
27638         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
27639         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
27640         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
27641         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
27642         return tag_ptr(ret_conv, true);
27643 }
27644
27645 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
27646         LDKChainMonitor this_arg_conv;
27647         this_arg_conv.inner = untag_ptr(this_arg);
27648         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27650         this_arg_conv.is_owned = false;
27651         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
27652         int64_tArray ret_arr = NULL;
27653         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
27654         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
27655         for (size_t k = 0; k < ret_var.datalen; k++) {
27656                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
27657                 int64_t ret_conv_10_ref = 0;
27658                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
27659                 ret_conv_10_ref = tag_ptr(ret_conv_10_var.inner, ret_conv_10_var.is_owned);
27660                 ret_arr_ptr[k] = ret_conv_10_ref;
27661         }
27662         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
27663         FREE(ret_var.data);
27664         return ret_arr;
27665 }
27666
27667 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) {
27668         LDKChainMonitor this_arg_conv;
27669         this_arg_conv.inner = untag_ptr(this_arg);
27670         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27672         this_arg_conv.is_owned = false;
27673         LDKOutPoint funding_txo_conv;
27674         funding_txo_conv.inner = untag_ptr(funding_txo);
27675         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
27676         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
27677         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
27678         LDKMonitorUpdateId completed_update_id_conv;
27679         completed_update_id_conv.inner = untag_ptr(completed_update_id);
27680         completed_update_id_conv.is_owned = ptr_is_owned(completed_update_id);
27681         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
27682         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
27683         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
27684         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
27685         return tag_ptr(ret_conv, true);
27686 }
27687
27688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
27689         LDKChainMonitor this_arg_conv;
27690         this_arg_conv.inner = untag_ptr(this_arg);
27691         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27693         this_arg_conv.is_owned = false;
27694         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
27695         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
27696         return tag_ptr(ret_ret, true);
27697 }
27698
27699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
27700         LDKChainMonitor this_arg_conv;
27701         this_arg_conv.inner = untag_ptr(this_arg);
27702         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27704         this_arg_conv.is_owned = false;
27705         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
27706         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
27707         return tag_ptr(ret_ret, true);
27708 }
27709
27710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
27711         LDKChainMonitor this_arg_conv;
27712         this_arg_conv.inner = untag_ptr(this_arg);
27713         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27715         this_arg_conv.is_owned = false;
27716         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
27717         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
27718         return tag_ptr(ret_ret, true);
27719 }
27720
27721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
27722         LDKChainMonitor this_arg_conv;
27723         this_arg_conv.inner = untag_ptr(this_arg);
27724         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27726         this_arg_conv.is_owned = false;
27727         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
27728         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
27729         return tag_ptr(ret_ret, true);
27730 }
27731
27732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27733         LDKChannelMonitorUpdate this_obj_conv;
27734         this_obj_conv.inner = untag_ptr(this_obj);
27735         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27737         ChannelMonitorUpdate_free(this_obj_conv);
27738 }
27739
27740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27741         LDKChannelMonitorUpdate this_ptr_conv;
27742         this_ptr_conv.inner = untag_ptr(this_ptr);
27743         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27745         this_ptr_conv.is_owned = false;
27746         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
27747         return ret_conv;
27748 }
27749
27750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27751         LDKChannelMonitorUpdate this_ptr_conv;
27752         this_ptr_conv.inner = untag_ptr(this_ptr);
27753         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27755         this_ptr_conv.is_owned = false;
27756         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
27757 }
27758
27759 static inline uint64_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
27760         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
27761         int64_t ret_ref = 0;
27762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27763         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27764         return ret_ref;
27765 }
27766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27767         LDKChannelMonitorUpdate arg_conv;
27768         arg_conv.inner = untag_ptr(arg);
27769         arg_conv.is_owned = ptr_is_owned(arg);
27770         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27771         arg_conv.is_owned = false;
27772         int64_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
27773         return ret_conv;
27774 }
27775
27776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27777         LDKChannelMonitorUpdate orig_conv;
27778         orig_conv.inner = untag_ptr(orig);
27779         orig_conv.is_owned = ptr_is_owned(orig);
27780         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27781         orig_conv.is_owned = false;
27782         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
27783         int64_t ret_ref = 0;
27784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27785         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27786         return ret_ref;
27787 }
27788
27789 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
27790         LDKChannelMonitorUpdate obj_conv;
27791         obj_conv.inner = untag_ptr(obj);
27792         obj_conv.is_owned = ptr_is_owned(obj);
27793         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27794         obj_conv.is_owned = false;
27795         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
27796         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27797         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27798         CVec_u8Z_free(ret_var);
27799         return ret_arr;
27800 }
27801
27802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27803         LDKu8slice ser_ref;
27804         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27805         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27806         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
27807         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
27808         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27809         return tag_ptr(ret_conv, true);
27810 }
27811
27812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27813         if (!ptr_is_owned(this_ptr)) return;
27814         void* this_ptr_ptr = untag_ptr(this_ptr);
27815         CHECK_ACCESS(this_ptr_ptr);
27816         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
27817         FREE(untag_ptr(this_ptr));
27818         MonitorEvent_free(this_ptr_conv);
27819 }
27820
27821 static inline uint64_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
27822         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27823         *ret_copy = MonitorEvent_clone(arg);
27824         int64_t ret_ref = tag_ptr(ret_copy, true);
27825         return ret_ref;
27826 }
27827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27828         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)untag_ptr(arg);
27829         int64_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
27830         return ret_conv;
27831 }
27832
27833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27834         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)untag_ptr(orig);
27835         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27836         *ret_copy = MonitorEvent_clone(orig_conv);
27837         int64_t ret_ref = tag_ptr(ret_copy, true);
27838         return ret_ref;
27839 }
27840
27841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
27842         LDKHTLCUpdate a_conv;
27843         a_conv.inner = untag_ptr(a);
27844         a_conv.is_owned = ptr_is_owned(a);
27845         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27846         a_conv = HTLCUpdate_clone(&a_conv);
27847         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27848         *ret_copy = MonitorEvent_htlcevent(a_conv);
27849         int64_t ret_ref = tag_ptr(ret_copy, true);
27850         return ret_ref;
27851 }
27852
27853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
27854         LDKOutPoint a_conv;
27855         a_conv.inner = untag_ptr(a);
27856         a_conv.is_owned = ptr_is_owned(a);
27857         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27858         a_conv = OutPoint_clone(&a_conv);
27859         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27860         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
27861         int64_t ret_ref = tag_ptr(ret_copy, true);
27862         return ret_ref;
27863 }
27864
27865 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) {
27866         LDKOutPoint funding_txo_conv;
27867         funding_txo_conv.inner = untag_ptr(funding_txo);
27868         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
27869         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
27870         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
27871         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27872         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
27873         int64_t ret_ref = tag_ptr(ret_copy, true);
27874         return ret_ref;
27875 }
27876
27877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
27878         LDKOutPoint a_conv;
27879         a_conv.inner = untag_ptr(a);
27880         a_conv.is_owned = ptr_is_owned(a);
27881         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27882         a_conv = OutPoint_clone(&a_conv);
27883         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
27884         *ret_copy = MonitorEvent_update_failed(a_conv);
27885         int64_t ret_ref = tag_ptr(ret_copy, true);
27886         return ret_ref;
27887 }
27888
27889 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
27890         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)untag_ptr(obj);
27891         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
27892         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27893         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27894         CVec_u8Z_free(ret_var);
27895         return ret_arr;
27896 }
27897
27898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27899         LDKu8slice ser_ref;
27900         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27901         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27902         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
27903         *ret_conv = MonitorEvent_read(ser_ref);
27904         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27905         return tag_ptr(ret_conv, true);
27906 }
27907
27908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27909         LDKHTLCUpdate this_obj_conv;
27910         this_obj_conv.inner = untag_ptr(this_obj);
27911         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27913         HTLCUpdate_free(this_obj_conv);
27914 }
27915
27916 static inline uint64_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
27917         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
27918         int64_t ret_ref = 0;
27919         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27920         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27921         return ret_ref;
27922 }
27923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27924         LDKHTLCUpdate arg_conv;
27925         arg_conv.inner = untag_ptr(arg);
27926         arg_conv.is_owned = ptr_is_owned(arg);
27927         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27928         arg_conv.is_owned = false;
27929         int64_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
27930         return ret_conv;
27931 }
27932
27933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27934         LDKHTLCUpdate orig_conv;
27935         orig_conv.inner = untag_ptr(orig);
27936         orig_conv.is_owned = ptr_is_owned(orig);
27937         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27938         orig_conv.is_owned = false;
27939         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
27940         int64_t ret_ref = 0;
27941         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27942         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27943         return ret_ref;
27944 }
27945
27946 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
27947         LDKHTLCUpdate obj_conv;
27948         obj_conv.inner = untag_ptr(obj);
27949         obj_conv.is_owned = ptr_is_owned(obj);
27950         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
27951         obj_conv.is_owned = false;
27952         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
27953         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27954         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27955         CVec_u8Z_free(ret_var);
27956         return ret_arr;
27957 }
27958
27959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
27960         LDKu8slice ser_ref;
27961         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
27962         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
27963         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
27964         *ret_conv = HTLCUpdate_read(ser_ref);
27965         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
27966         return tag_ptr(ret_conv, true);
27967 }
27968
27969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27970         if (!ptr_is_owned(this_ptr)) return;
27971         void* this_ptr_ptr = untag_ptr(this_ptr);
27972         CHECK_ACCESS(this_ptr_ptr);
27973         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
27974         FREE(untag_ptr(this_ptr));
27975         Balance_free(this_ptr_conv);
27976 }
27977
27978 static inline uint64_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
27979         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27980         *ret_copy = Balance_clone(arg);
27981         int64_t ret_ref = tag_ptr(ret_copy, true);
27982         return ret_ref;
27983 }
27984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27985         LDKBalance* arg_conv = (LDKBalance*)untag_ptr(arg);
27986         int64_t ret_conv = Balance_clone_ptr(arg_conv);
27987         return ret_conv;
27988 }
27989
27990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27991         LDKBalance* orig_conv = (LDKBalance*)untag_ptr(orig);
27992         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
27993         *ret_copy = Balance_clone(orig_conv);
27994         int64_t ret_ref = tag_ptr(ret_copy, true);
27995         return ret_ref;
27996 }
27997
27998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
27999         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28000         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
28001         int64_t ret_ref = tag_ptr(ret_copy, true);
28002         return ret_ref;
28003 }
28004
28005 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) {
28006         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28007         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
28008         int64_t ret_ref = tag_ptr(ret_copy, true);
28009         return ret_ref;
28010 }
28011
28012 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) {
28013         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28014         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
28015         int64_t ret_ref = tag_ptr(ret_copy, true);
28016         return ret_ref;
28017 }
28018
28019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1maybe_1timeout_1claimable_1htlc(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t claimable_height) {
28020         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28021         *ret_copy = Balance_maybe_timeout_claimable_htlc(claimable_amount_satoshis, claimable_height);
28022         int64_t ret_ref = tag_ptr(ret_copy, true);
28023         return ret_ref;
28024 }
28025
28026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1maybe_1preimage_1claimable_1htlc(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t expiry_height) {
28027         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28028         *ret_copy = Balance_maybe_preimage_claimable_htlc(claimable_amount_satoshis, expiry_height);
28029         int64_t ret_ref = tag_ptr(ret_copy, true);
28030         return ret_ref;
28031 }
28032
28033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1counterparty_1revoked_1output_1claimable(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
28034         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28035         *ret_copy = Balance_counterparty_revoked_output_claimable(claimable_amount_satoshis);
28036         int64_t ret_ref = tag_ptr(ret_copy, true);
28037         return ret_ref;
28038 }
28039
28040 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28041         LDKBalance* a_conv = (LDKBalance*)untag_ptr(a);
28042         LDKBalance* b_conv = (LDKBalance*)untag_ptr(b);
28043         jboolean ret_conv = Balance_eq(a_conv, b_conv);
28044         return ret_conv;
28045 }
28046
28047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28048         LDKChannelMonitor this_obj_conv;
28049         this_obj_conv.inner = untag_ptr(this_obj);
28050         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28052         ChannelMonitor_free(this_obj_conv);
28053 }
28054
28055 static inline uint64_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
28056         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
28057         int64_t ret_ref = 0;
28058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28059         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28060         return ret_ref;
28061 }
28062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28063         LDKChannelMonitor arg_conv;
28064         arg_conv.inner = untag_ptr(arg);
28065         arg_conv.is_owned = ptr_is_owned(arg);
28066         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28067         arg_conv.is_owned = false;
28068         int64_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
28069         return ret_conv;
28070 }
28071
28072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28073         LDKChannelMonitor orig_conv;
28074         orig_conv.inner = untag_ptr(orig);
28075         orig_conv.is_owned = ptr_is_owned(orig);
28076         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28077         orig_conv.is_owned = false;
28078         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
28079         int64_t ret_ref = 0;
28080         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28081         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28082         return ret_ref;
28083 }
28084
28085 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
28086         LDKChannelMonitor obj_conv;
28087         obj_conv.inner = untag_ptr(obj);
28088         obj_conv.is_owned = ptr_is_owned(obj);
28089         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28090         obj_conv.is_owned = false;
28091         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
28092         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28093         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28094         CVec_u8Z_free(ret_var);
28095         return ret_arr;
28096 }
28097
28098 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) {
28099         LDKChannelMonitor this_arg_conv;
28100         this_arg_conv.inner = untag_ptr(this_arg);
28101         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28103         this_arg_conv.is_owned = false;
28104         LDKChannelMonitorUpdate updates_conv;
28105         updates_conv.inner = untag_ptr(updates);
28106         updates_conv.is_owned = ptr_is_owned(updates);
28107         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
28108         updates_conv.is_owned = false;
28109         void* broadcaster_ptr = untag_ptr(broadcaster);
28110         if (ptr_is_owned(broadcaster)) { CHECK_ACCESS(broadcaster_ptr); }
28111         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
28112         void* fee_estimator_ptr = untag_ptr(fee_estimator);
28113         CHECK_ACCESS(fee_estimator_ptr);
28114         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
28115         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
28116                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28117                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
28118         }
28119         void* logger_ptr = untag_ptr(logger);
28120         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
28121         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
28122         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
28123         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
28124         return tag_ptr(ret_conv, true);
28125 }
28126
28127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
28128         LDKChannelMonitor this_arg_conv;
28129         this_arg_conv.inner = untag_ptr(this_arg);
28130         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28132         this_arg_conv.is_owned = false;
28133         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
28134         return ret_conv;
28135 }
28136
28137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
28138         LDKChannelMonitor this_arg_conv;
28139         this_arg_conv.inner = untag_ptr(this_arg);
28140         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28142         this_arg_conv.is_owned = false;
28143         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
28144         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
28145         return tag_ptr(ret_conv, true);
28146 }
28147
28148 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
28149         LDKChannelMonitor this_arg_conv;
28150         this_arg_conv.inner = untag_ptr(this_arg);
28151         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28153         this_arg_conv.is_owned = false;
28154         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
28155         int64_tArray ret_arr = NULL;
28156         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28157         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28158         for (size_t o = 0; o < ret_var.datalen; o++) {
28159                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
28160                 *ret_conv_40_conv = ret_var.data[o];
28161                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
28162         }
28163         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28164         FREE(ret_var.data);
28165         return ret_arr;
28166 }
28167
28168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
28169         LDKChannelMonitor this_arg_conv;
28170         this_arg_conv.inner = untag_ptr(this_arg);
28171         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28173         this_arg_conv.is_owned = false;
28174         void* filter_ptr = untag_ptr(filter);
28175         if (ptr_is_owned(filter)) { CHECK_ACCESS(filter_ptr); }
28176         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
28177         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
28178 }
28179
28180 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
28181         LDKChannelMonitor this_arg_conv;
28182         this_arg_conv.inner = untag_ptr(this_arg);
28183         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28185         this_arg_conv.is_owned = false;
28186         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
28187         int64_tArray ret_arr = NULL;
28188         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28189         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28190         for (size_t o = 0; o < ret_var.datalen; o++) {
28191                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
28192                 *ret_conv_14_copy = ret_var.data[o];
28193                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
28194                 ret_arr_ptr[o] = ret_conv_14_ref;
28195         }
28196         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28197         FREE(ret_var.data);
28198         return ret_arr;
28199 }
28200
28201 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
28202         LDKChannelMonitor this_arg_conv;
28203         this_arg_conv.inner = untag_ptr(this_arg);
28204         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28206         this_arg_conv.is_owned = false;
28207         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
28208         int64_tArray ret_arr = NULL;
28209         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28210         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28211         for (size_t h = 0; h < ret_var.datalen; h++) {
28212                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
28213                 *ret_conv_7_copy = ret_var.data[h];
28214                 int64_t ret_conv_7_ref = tag_ptr(ret_conv_7_copy, true);
28215                 ret_arr_ptr[h] = ret_conv_7_ref;
28216         }
28217         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28218         FREE(ret_var.data);
28219         return ret_arr;
28220 }
28221
28222 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1counterparty_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
28223         LDKChannelMonitor this_arg_conv;
28224         this_arg_conv.inner = untag_ptr(this_arg);
28225         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28227         this_arg_conv.is_owned = false;
28228         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28229         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelMonitor_get_counterparty_node_id(&this_arg_conv).compressed_form);
28230         return ret_arr;
28231 }
28232
28233 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) {
28234         LDKChannelMonitor this_arg_conv;
28235         this_arg_conv.inner = untag_ptr(this_arg);
28236         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28238         this_arg_conv.is_owned = false;
28239         void* logger_ptr = untag_ptr(logger);
28240         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
28241         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
28242         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
28243         jobjectArray ret_arr = NULL;
28244         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
28245         ;
28246         for (size_t i = 0; i < ret_var.datalen; i++) {
28247                 LDKTransaction ret_conv_8_var = ret_var.data[i];
28248                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
28249                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
28250                 Transaction_free(ret_conv_8_var);
28251                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
28252         }
28253         
28254         FREE(ret_var.data);
28255         return ret_arr;
28256 }
28257
28258 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) {
28259         LDKChannelMonitor this_arg_conv;
28260         this_arg_conv.inner = untag_ptr(this_arg);
28261         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28263         this_arg_conv.is_owned = false;
28264         unsigned char header_arr[80];
28265         CHECK((*env)->GetArrayLength(env, header) == 80);
28266         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
28267         unsigned char (*header_ref)[80] = &header_arr;
28268         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
28269         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
28270         if (txdata_constr.datalen > 0)
28271                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
28272         else
28273                 txdata_constr.data = NULL;
28274         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
28275         for (size_t c = 0; c < txdata_constr.datalen; c++) {
28276                 int64_t txdata_conv_28 = txdata_vals[c];
28277                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
28278                 CHECK_ACCESS(txdata_conv_28_ptr);
28279                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
28280                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
28281                 txdata_constr.data[c] = txdata_conv_28_conv;
28282         }
28283         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
28284         void* broadcaster_ptr = untag_ptr(broadcaster);
28285         CHECK_ACCESS(broadcaster_ptr);
28286         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
28287         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28288                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28289                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
28290         }
28291         void* fee_estimator_ptr = untag_ptr(fee_estimator);
28292         CHECK_ACCESS(fee_estimator_ptr);
28293         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
28294         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
28295                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28296                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
28297         }
28298         void* logger_ptr = untag_ptr(logger);
28299         CHECK_ACCESS(logger_ptr);
28300         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28301         if (logger_conv.free == LDKLogger_JCalls_free) {
28302                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28303                 LDKLogger_JCalls_cloned(&logger_conv);
28304         }
28305         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);
28306         int64_tArray ret_arr = NULL;
28307         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28308         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28309         for (size_t n = 0; n < ret_var.datalen; n++) {
28310                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
28311                 *ret_conv_39_conv = ret_var.data[n];
28312                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
28313         }
28314         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28315         FREE(ret_var.data);
28316         return ret_arr;
28317 }
28318
28319 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) {
28320         LDKChannelMonitor this_arg_conv;
28321         this_arg_conv.inner = untag_ptr(this_arg);
28322         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28324         this_arg_conv.is_owned = false;
28325         unsigned char header_arr[80];
28326         CHECK((*env)->GetArrayLength(env, header) == 80);
28327         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
28328         unsigned char (*header_ref)[80] = &header_arr;
28329         void* broadcaster_ptr = untag_ptr(broadcaster);
28330         CHECK_ACCESS(broadcaster_ptr);
28331         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
28332         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28333                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28334                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
28335         }
28336         void* fee_estimator_ptr = untag_ptr(fee_estimator);
28337         CHECK_ACCESS(fee_estimator_ptr);
28338         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
28339         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
28340                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28341                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
28342         }
28343         void* logger_ptr = untag_ptr(logger);
28344         CHECK_ACCESS(logger_ptr);
28345         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28346         if (logger_conv.free == LDKLogger_JCalls_free) {
28347                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28348                 LDKLogger_JCalls_cloned(&logger_conv);
28349         }
28350         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
28351 }
28352
28353 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) {
28354         LDKChannelMonitor this_arg_conv;
28355         this_arg_conv.inner = untag_ptr(this_arg);
28356         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28358         this_arg_conv.is_owned = false;
28359         unsigned char header_arr[80];
28360         CHECK((*env)->GetArrayLength(env, header) == 80);
28361         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
28362         unsigned char (*header_ref)[80] = &header_arr;
28363         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
28364         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
28365         if (txdata_constr.datalen > 0)
28366                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
28367         else
28368                 txdata_constr.data = NULL;
28369         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
28370         for (size_t c = 0; c < txdata_constr.datalen; c++) {
28371                 int64_t txdata_conv_28 = txdata_vals[c];
28372                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
28373                 CHECK_ACCESS(txdata_conv_28_ptr);
28374                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
28375                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
28376                 txdata_constr.data[c] = txdata_conv_28_conv;
28377         }
28378         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
28379         void* broadcaster_ptr = untag_ptr(broadcaster);
28380         CHECK_ACCESS(broadcaster_ptr);
28381         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
28382         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28383                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28384                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
28385         }
28386         void* fee_estimator_ptr = untag_ptr(fee_estimator);
28387         CHECK_ACCESS(fee_estimator_ptr);
28388         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
28389         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
28390                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28391                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
28392         }
28393         void* logger_ptr = untag_ptr(logger);
28394         CHECK_ACCESS(logger_ptr);
28395         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28396         if (logger_conv.free == LDKLogger_JCalls_free) {
28397                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28398                 LDKLogger_JCalls_cloned(&logger_conv);
28399         }
28400         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);
28401         int64_tArray ret_arr = NULL;
28402         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28403         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28404         for (size_t n = 0; n < ret_var.datalen; n++) {
28405                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
28406                 *ret_conv_39_conv = ret_var.data[n];
28407                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
28408         }
28409         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28410         FREE(ret_var.data);
28411         return ret_arr;
28412 }
28413
28414 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) {
28415         LDKChannelMonitor this_arg_conv;
28416         this_arg_conv.inner = untag_ptr(this_arg);
28417         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28419         this_arg_conv.is_owned = false;
28420         unsigned char txid_arr[32];
28421         CHECK((*env)->GetArrayLength(env, txid) == 32);
28422         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
28423         unsigned char (*txid_ref)[32] = &txid_arr;
28424         void* broadcaster_ptr = untag_ptr(broadcaster);
28425         CHECK_ACCESS(broadcaster_ptr);
28426         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
28427         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28428                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28429                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
28430         }
28431         void* fee_estimator_ptr = untag_ptr(fee_estimator);
28432         CHECK_ACCESS(fee_estimator_ptr);
28433         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
28434         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
28435                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28436                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
28437         }
28438         void* logger_ptr = untag_ptr(logger);
28439         CHECK_ACCESS(logger_ptr);
28440         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28441         if (logger_conv.free == LDKLogger_JCalls_free) {
28442                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28443                 LDKLogger_JCalls_cloned(&logger_conv);
28444         }
28445         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
28446 }
28447
28448 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) {
28449         LDKChannelMonitor this_arg_conv;
28450         this_arg_conv.inner = untag_ptr(this_arg);
28451         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28453         this_arg_conv.is_owned = false;
28454         unsigned char header_arr[80];
28455         CHECK((*env)->GetArrayLength(env, header) == 80);
28456         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
28457         unsigned char (*header_ref)[80] = &header_arr;
28458         void* broadcaster_ptr = untag_ptr(broadcaster);
28459         CHECK_ACCESS(broadcaster_ptr);
28460         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
28461         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28462                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28463                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
28464         }
28465         void* fee_estimator_ptr = untag_ptr(fee_estimator);
28466         CHECK_ACCESS(fee_estimator_ptr);
28467         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
28468         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
28469                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28470                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
28471         }
28472         void* logger_ptr = untag_ptr(logger);
28473         CHECK_ACCESS(logger_ptr);
28474         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28475         if (logger_conv.free == LDKLogger_JCalls_free) {
28476                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28477                 LDKLogger_JCalls_cloned(&logger_conv);
28478         }
28479         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
28480         int64_tArray ret_arr = NULL;
28481         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28482         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28483         for (size_t n = 0; n < ret_var.datalen; n++) {
28484                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
28485                 *ret_conv_39_conv = ret_var.data[n];
28486                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
28487         }
28488         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28489         FREE(ret_var.data);
28490         return ret_arr;
28491 }
28492
28493 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
28494         LDKChannelMonitor this_arg_conv;
28495         this_arg_conv.inner = untag_ptr(this_arg);
28496         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28498         this_arg_conv.is_owned = false;
28499         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
28500         jobjectArray ret_arr = NULL;
28501         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
28502         ;
28503         for (size_t i = 0; i < ret_var.datalen; i++) {
28504                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
28505                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
28506                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
28507         }
28508         
28509         FREE(ret_var.data);
28510         return ret_arr;
28511 }
28512
28513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
28514         LDKChannelMonitor this_arg_conv;
28515         this_arg_conv.inner = untag_ptr(this_arg);
28516         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28518         this_arg_conv.is_owned = false;
28519         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
28520         int64_t ret_ref = 0;
28521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28522         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28523         return ret_ref;
28524 }
28525
28526 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
28527         LDKChannelMonitor this_arg_conv;
28528         this_arg_conv.inner = untag_ptr(this_arg);
28529         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28531         this_arg_conv.is_owned = false;
28532         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
28533         int64_tArray ret_arr = NULL;
28534         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28535         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28536         for (size_t j = 0; j < ret_var.datalen; j++) {
28537                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28538                 *ret_conv_9_copy = ret_var.data[j];
28539                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
28540                 ret_arr_ptr[j] = ret_conv_9_ref;
28541         }
28542         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28543         FREE(ret_var.data);
28544         return ret_arr;
28545 }
28546
28547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
28548         LDKu8slice ser_ref;
28549         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28550         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28551         void* arg_ptr = untag_ptr(arg);
28552         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
28553         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
28554         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
28555         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
28556         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28557         return tag_ptr(ret_conv, true);
28558 }
28559
28560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28561         LDKOutPoint this_obj_conv;
28562         this_obj_conv.inner = untag_ptr(this_obj);
28563         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28565         OutPoint_free(this_obj_conv);
28566 }
28567
28568 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
28569         LDKOutPoint this_ptr_conv;
28570         this_ptr_conv.inner = untag_ptr(this_ptr);
28571         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28573         this_ptr_conv.is_owned = false;
28574         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28575         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
28576         return ret_arr;
28577 }
28578
28579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28580         LDKOutPoint this_ptr_conv;
28581         this_ptr_conv.inner = untag_ptr(this_ptr);
28582         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28584         this_ptr_conv.is_owned = false;
28585         LDKThirtyTwoBytes val_ref;
28586         CHECK((*env)->GetArrayLength(env, val) == 32);
28587         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28588         OutPoint_set_txid(&this_ptr_conv, val_ref);
28589 }
28590
28591 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
28592         LDKOutPoint this_ptr_conv;
28593         this_ptr_conv.inner = untag_ptr(this_ptr);
28594         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28596         this_ptr_conv.is_owned = false;
28597         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
28598         return ret_conv;
28599 }
28600
28601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28602         LDKOutPoint this_ptr_conv;
28603         this_ptr_conv.inner = untag_ptr(this_ptr);
28604         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28606         this_ptr_conv.is_owned = false;
28607         OutPoint_set_index(&this_ptr_conv, val);
28608 }
28609
28610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
28611         LDKThirtyTwoBytes txid_arg_ref;
28612         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
28613         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
28614         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
28615         int64_t ret_ref = 0;
28616         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28617         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28618         return ret_ref;
28619 }
28620
28621 static inline uint64_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
28622         LDKOutPoint ret_var = OutPoint_clone(arg);
28623         int64_t ret_ref = 0;
28624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28625         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28626         return ret_ref;
28627 }
28628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28629         LDKOutPoint arg_conv;
28630         arg_conv.inner = untag_ptr(arg);
28631         arg_conv.is_owned = ptr_is_owned(arg);
28632         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28633         arg_conv.is_owned = false;
28634         int64_t ret_conv = OutPoint_clone_ptr(&arg_conv);
28635         return ret_conv;
28636 }
28637
28638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28639         LDKOutPoint orig_conv;
28640         orig_conv.inner = untag_ptr(orig);
28641         orig_conv.is_owned = ptr_is_owned(orig);
28642         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28643         orig_conv.is_owned = false;
28644         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
28645         int64_t ret_ref = 0;
28646         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28647         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28648         return ret_ref;
28649 }
28650
28651 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28652         LDKOutPoint a_conv;
28653         a_conv.inner = untag_ptr(a);
28654         a_conv.is_owned = ptr_is_owned(a);
28655         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28656         a_conv.is_owned = false;
28657         LDKOutPoint b_conv;
28658         b_conv.inner = untag_ptr(b);
28659         b_conv.is_owned = ptr_is_owned(b);
28660         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28661         b_conv.is_owned = false;
28662         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
28663         return ret_conv;
28664 }
28665
28666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
28667         LDKOutPoint o_conv;
28668         o_conv.inner = untag_ptr(o);
28669         o_conv.is_owned = ptr_is_owned(o);
28670         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28671         o_conv.is_owned = false;
28672         int64_t ret_conv = OutPoint_hash(&o_conv);
28673         return ret_conv;
28674 }
28675
28676 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
28677         LDKOutPoint this_arg_conv;
28678         this_arg_conv.inner = untag_ptr(this_arg);
28679         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28681         this_arg_conv.is_owned = false;
28682         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28683         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
28684         return ret_arr;
28685 }
28686
28687 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
28688         LDKOutPoint obj_conv;
28689         obj_conv.inner = untag_ptr(obj);
28690         obj_conv.is_owned = ptr_is_owned(obj);
28691         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28692         obj_conv.is_owned = false;
28693         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
28694         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28695         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28696         CVec_u8Z_free(ret_var);
28697         return ret_arr;
28698 }
28699
28700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28701         LDKu8slice ser_ref;
28702         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28703         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28704         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
28705         *ret_conv = OutPoint_read(ser_ref);
28706         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28707         return tag_ptr(ret_conv, true);
28708 }
28709
28710 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28711         LDKDelayedPaymentOutputDescriptor this_obj_conv;
28712         this_obj_conv.inner = untag_ptr(this_obj);
28713         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28715         DelayedPaymentOutputDescriptor_free(this_obj_conv);
28716 }
28717
28718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
28719         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28720         this_ptr_conv.inner = untag_ptr(this_ptr);
28721         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28723         this_ptr_conv.is_owned = false;
28724         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
28725         int64_t ret_ref = 0;
28726         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28727         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28728         return ret_ref;
28729 }
28730
28731 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28732         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28733         this_ptr_conv.inner = untag_ptr(this_ptr);
28734         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28735         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28736         this_ptr_conv.is_owned = false;
28737         LDKOutPoint val_conv;
28738         val_conv.inner = untag_ptr(val);
28739         val_conv.is_owned = ptr_is_owned(val);
28740         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28741         val_conv = OutPoint_clone(&val_conv);
28742         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
28743 }
28744
28745 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
28746         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28747         this_ptr_conv.inner = untag_ptr(this_ptr);
28748         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28750         this_ptr_conv.is_owned = false;
28751         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28752         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
28753         return ret_arr;
28754 }
28755
28756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28757         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28758         this_ptr_conv.inner = untag_ptr(this_ptr);
28759         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28761         this_ptr_conv.is_owned = false;
28762         LDKPublicKey val_ref;
28763         CHECK((*env)->GetArrayLength(env, val) == 33);
28764         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28765         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
28766 }
28767
28768 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
28769         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28770         this_ptr_conv.inner = untag_ptr(this_ptr);
28771         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28773         this_ptr_conv.is_owned = false;
28774         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
28775         return ret_conv;
28776 }
28777
28778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28779         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28780         this_ptr_conv.inner = untag_ptr(this_ptr);
28781         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28783         this_ptr_conv.is_owned = false;
28784         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
28785 }
28786
28787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
28788         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28789         this_ptr_conv.inner = untag_ptr(this_ptr);
28790         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28792         this_ptr_conv.is_owned = false;
28793         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
28794         *ret_ref = DelayedPaymentOutputDescriptor_get_output(&this_ptr_conv);
28795         return tag_ptr(ret_ref, true);
28796 }
28797
28798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28799         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28800         this_ptr_conv.inner = untag_ptr(this_ptr);
28801         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28803         this_ptr_conv.is_owned = false;
28804         void* val_ptr = untag_ptr(val);
28805         CHECK_ACCESS(val_ptr);
28806         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
28807         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
28808         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
28809 }
28810
28811 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
28812         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28813         this_ptr_conv.inner = untag_ptr(this_ptr);
28814         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28816         this_ptr_conv.is_owned = false;
28817         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28818         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
28819         return ret_arr;
28820 }
28821
28822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28823         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28824         this_ptr_conv.inner = untag_ptr(this_ptr);
28825         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28827         this_ptr_conv.is_owned = false;
28828         LDKPublicKey val_ref;
28829         CHECK((*env)->GetArrayLength(env, val) == 33);
28830         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28831         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
28832 }
28833
28834 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28835         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28836         this_ptr_conv.inner = untag_ptr(this_ptr);
28837         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28839         this_ptr_conv.is_owned = false;
28840         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28841         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
28842         return ret_arr;
28843 }
28844
28845 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28846         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28847         this_ptr_conv.inner = untag_ptr(this_ptr);
28848         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28850         this_ptr_conv.is_owned = false;
28851         LDKThirtyTwoBytes val_ref;
28852         CHECK((*env)->GetArrayLength(env, val) == 32);
28853         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28854         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
28855 }
28856
28857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
28858         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28859         this_ptr_conv.inner = untag_ptr(this_ptr);
28860         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28862         this_ptr_conv.is_owned = false;
28863         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
28864         return ret_conv;
28865 }
28866
28867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28868         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
28869         this_ptr_conv.inner = untag_ptr(this_ptr);
28870         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28872         this_ptr_conv.is_owned = false;
28873         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
28874 }
28875
28876 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) {
28877         LDKOutPoint outpoint_arg_conv;
28878         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
28879         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
28880         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
28881         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
28882         LDKPublicKey per_commitment_point_arg_ref;
28883         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
28884         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
28885         void* output_arg_ptr = untag_ptr(output_arg);
28886         CHECK_ACCESS(output_arg_ptr);
28887         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
28888         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
28889         LDKPublicKey revocation_pubkey_arg_ref;
28890         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
28891         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
28892         LDKThirtyTwoBytes channel_keys_id_arg_ref;
28893         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
28894         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
28895         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);
28896         int64_t ret_ref = 0;
28897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28898         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28899         return ret_ref;
28900 }
28901
28902 static inline uint64_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
28903         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
28904         int64_t ret_ref = 0;
28905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28906         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28907         return ret_ref;
28908 }
28909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28910         LDKDelayedPaymentOutputDescriptor arg_conv;
28911         arg_conv.inner = untag_ptr(arg);
28912         arg_conv.is_owned = ptr_is_owned(arg);
28913         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28914         arg_conv.is_owned = false;
28915         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
28916         return ret_conv;
28917 }
28918
28919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28920         LDKDelayedPaymentOutputDescriptor orig_conv;
28921         orig_conv.inner = untag_ptr(orig);
28922         orig_conv.is_owned = ptr_is_owned(orig);
28923         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28924         orig_conv.is_owned = false;
28925         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
28926         int64_t ret_ref = 0;
28927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28928         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28929         return ret_ref;
28930 }
28931
28932 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
28933         LDKDelayedPaymentOutputDescriptor obj_conv;
28934         obj_conv.inner = untag_ptr(obj);
28935         obj_conv.is_owned = ptr_is_owned(obj);
28936         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28937         obj_conv.is_owned = false;
28938         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
28939         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28940         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28941         CVec_u8Z_free(ret_var);
28942         return ret_arr;
28943 }
28944
28945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28946         LDKu8slice ser_ref;
28947         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28948         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28949         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
28950         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
28951         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28952         return tag_ptr(ret_conv, true);
28953 }
28954
28955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28956         LDKStaticPaymentOutputDescriptor this_obj_conv;
28957         this_obj_conv.inner = untag_ptr(this_obj);
28958         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28960         StaticPaymentOutputDescriptor_free(this_obj_conv);
28961 }
28962
28963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
28964         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28965         this_ptr_conv.inner = untag_ptr(this_ptr);
28966         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28968         this_ptr_conv.is_owned = false;
28969         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
28970         int64_t ret_ref = 0;
28971         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28972         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28973         return ret_ref;
28974 }
28975
28976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28977         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28978         this_ptr_conv.inner = untag_ptr(this_ptr);
28979         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28981         this_ptr_conv.is_owned = false;
28982         LDKOutPoint val_conv;
28983         val_conv.inner = untag_ptr(val);
28984         val_conv.is_owned = ptr_is_owned(val);
28985         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28986         val_conv = OutPoint_clone(&val_conv);
28987         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
28988 }
28989
28990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
28991         LDKStaticPaymentOutputDescriptor this_ptr_conv;
28992         this_ptr_conv.inner = untag_ptr(this_ptr);
28993         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28995         this_ptr_conv.is_owned = false;
28996         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
28997         *ret_ref = StaticPaymentOutputDescriptor_get_output(&this_ptr_conv);
28998         return tag_ptr(ret_ref, true);
28999 }
29000
29001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29002         LDKStaticPaymentOutputDescriptor this_ptr_conv;
29003         this_ptr_conv.inner = untag_ptr(this_ptr);
29004         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29006         this_ptr_conv.is_owned = false;
29007         void* val_ptr = untag_ptr(val);
29008         CHECK_ACCESS(val_ptr);
29009         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
29010         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
29011         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
29012 }
29013
29014 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29015         LDKStaticPaymentOutputDescriptor this_ptr_conv;
29016         this_ptr_conv.inner = untag_ptr(this_ptr);
29017         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29019         this_ptr_conv.is_owned = false;
29020         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29021         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
29022         return ret_arr;
29023 }
29024
29025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29026         LDKStaticPaymentOutputDescriptor this_ptr_conv;
29027         this_ptr_conv.inner = untag_ptr(this_ptr);
29028         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29030         this_ptr_conv.is_owned = false;
29031         LDKThirtyTwoBytes val_ref;
29032         CHECK((*env)->GetArrayLength(env, val) == 32);
29033         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29034         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
29035 }
29036
29037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
29038         LDKStaticPaymentOutputDescriptor this_ptr_conv;
29039         this_ptr_conv.inner = untag_ptr(this_ptr);
29040         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29042         this_ptr_conv.is_owned = false;
29043         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
29044         return ret_conv;
29045 }
29046
29047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29048         LDKStaticPaymentOutputDescriptor this_ptr_conv;
29049         this_ptr_conv.inner = untag_ptr(this_ptr);
29050         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29052         this_ptr_conv.is_owned = false;
29053         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
29054 }
29055
29056 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) {
29057         LDKOutPoint outpoint_arg_conv;
29058         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
29059         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
29060         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
29061         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
29062         void* output_arg_ptr = untag_ptr(output_arg);
29063         CHECK_ACCESS(output_arg_ptr);
29064         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
29065         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
29066         LDKThirtyTwoBytes channel_keys_id_arg_ref;
29067         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
29068         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
29069         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
29070         int64_t ret_ref = 0;
29071         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29072         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29073         return ret_ref;
29074 }
29075
29076 static inline uint64_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
29077         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
29078         int64_t ret_ref = 0;
29079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29080         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29081         return ret_ref;
29082 }
29083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29084         LDKStaticPaymentOutputDescriptor arg_conv;
29085         arg_conv.inner = untag_ptr(arg);
29086         arg_conv.is_owned = ptr_is_owned(arg);
29087         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29088         arg_conv.is_owned = false;
29089         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
29090         return ret_conv;
29091 }
29092
29093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29094         LDKStaticPaymentOutputDescriptor orig_conv;
29095         orig_conv.inner = untag_ptr(orig);
29096         orig_conv.is_owned = ptr_is_owned(orig);
29097         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29098         orig_conv.is_owned = false;
29099         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
29100         int64_t ret_ref = 0;
29101         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29102         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29103         return ret_ref;
29104 }
29105
29106 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
29107         LDKStaticPaymentOutputDescriptor obj_conv;
29108         obj_conv.inner = untag_ptr(obj);
29109         obj_conv.is_owned = ptr_is_owned(obj);
29110         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29111         obj_conv.is_owned = false;
29112         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
29113         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29114         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29115         CVec_u8Z_free(ret_var);
29116         return ret_arr;
29117 }
29118
29119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29120         LDKu8slice ser_ref;
29121         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29122         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29123         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
29124         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
29125         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29126         return tag_ptr(ret_conv, true);
29127 }
29128
29129 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29130         if (!ptr_is_owned(this_ptr)) return;
29131         void* this_ptr_ptr = untag_ptr(this_ptr);
29132         CHECK_ACCESS(this_ptr_ptr);
29133         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
29134         FREE(untag_ptr(this_ptr));
29135         SpendableOutputDescriptor_free(this_ptr_conv);
29136 }
29137
29138 static inline uint64_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
29139         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
29140         *ret_copy = SpendableOutputDescriptor_clone(arg);
29141         int64_t ret_ref = tag_ptr(ret_copy, true);
29142         return ret_ref;
29143 }
29144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29145         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)untag_ptr(arg);
29146         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
29147         return ret_conv;
29148 }
29149
29150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29151         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)untag_ptr(orig);
29152         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
29153         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
29154         int64_t ret_ref = tag_ptr(ret_copy, true);
29155         return ret_ref;
29156 }
29157
29158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
29159         LDKOutPoint outpoint_conv;
29160         outpoint_conv.inner = untag_ptr(outpoint);
29161         outpoint_conv.is_owned = ptr_is_owned(outpoint);
29162         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
29163         outpoint_conv = OutPoint_clone(&outpoint_conv);
29164         void* output_ptr = untag_ptr(output);
29165         CHECK_ACCESS(output_ptr);
29166         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
29167         output_conv = TxOut_clone((LDKTxOut*)untag_ptr(output));
29168         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
29169         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
29170         int64_t ret_ref = tag_ptr(ret_copy, true);
29171         return ret_ref;
29172 }
29173
29174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
29175         LDKDelayedPaymentOutputDescriptor a_conv;
29176         a_conv.inner = untag_ptr(a);
29177         a_conv.is_owned = ptr_is_owned(a);
29178         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29179         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
29180         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
29181         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
29182         int64_t ret_ref = tag_ptr(ret_copy, true);
29183         return ret_ref;
29184 }
29185
29186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
29187         LDKStaticPaymentOutputDescriptor a_conv;
29188         a_conv.inner = untag_ptr(a);
29189         a_conv.is_owned = ptr_is_owned(a);
29190         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29191         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
29192         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
29193         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
29194         int64_t ret_ref = tag_ptr(ret_copy, true);
29195         return ret_ref;
29196 }
29197
29198 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
29199         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)untag_ptr(obj);
29200         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
29201         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29202         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29203         CVec_u8Z_free(ret_var);
29204         return ret_arr;
29205 }
29206
29207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29208         LDKu8slice ser_ref;
29209         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29210         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29211         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
29212         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
29213         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29214         return tag_ptr(ret_conv, true);
29215 }
29216
29217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29218         if (!ptr_is_owned(this_ptr)) return;
29219         void* this_ptr_ptr = untag_ptr(this_ptr);
29220         CHECK_ACCESS(this_ptr_ptr);
29221         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
29222         FREE(untag_ptr(this_ptr));
29223         BaseSign_free(this_ptr_conv);
29224 }
29225
29226 static inline uint64_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
29227         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
29228         *ret_ret = Sign_clone(arg);
29229         return tag_ptr(ret_ret, true);
29230 }
29231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29232         void* arg_ptr = untag_ptr(arg);
29233         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
29234         LDKSign* arg_conv = (LDKSign*)arg_ptr;
29235         int64_t ret_conv = Sign_clone_ptr(arg_conv);
29236         return ret_conv;
29237 }
29238
29239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29240         void* orig_ptr = untag_ptr(orig);
29241         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
29242         LDKSign* orig_conv = (LDKSign*)orig_ptr;
29243         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
29244         *ret_ret = Sign_clone(orig_conv);
29245         return tag_ptr(ret_ret, true);
29246 }
29247
29248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29249         if (!ptr_is_owned(this_ptr)) return;
29250         void* this_ptr_ptr = untag_ptr(this_ptr);
29251         CHECK_ACCESS(this_ptr_ptr);
29252         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
29253         FREE(untag_ptr(this_ptr));
29254         Sign_free(this_ptr_conv);
29255 }
29256
29257 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29258         LDKRecipient* orig_conv = (LDKRecipient*)untag_ptr(orig);
29259         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
29260         return ret_conv;
29261 }
29262
29263 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
29264         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
29265         return ret_conv;
29266 }
29267
29268 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
29269         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
29270         return ret_conv;
29271 }
29272
29273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29274         if (!ptr_is_owned(this_ptr)) return;
29275         void* this_ptr_ptr = untag_ptr(this_ptr);
29276         CHECK_ACCESS(this_ptr_ptr);
29277         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
29278         FREE(untag_ptr(this_ptr));
29279         KeysInterface_free(this_ptr_conv);
29280 }
29281
29282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29283         LDKInMemorySigner this_obj_conv;
29284         this_obj_conv.inner = untag_ptr(this_obj);
29285         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29287         InMemorySigner_free(this_obj_conv);
29288 }
29289
29290 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
29291         LDKInMemorySigner this_ptr_conv;
29292         this_ptr_conv.inner = untag_ptr(this_ptr);
29293         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29295         this_ptr_conv.is_owned = false;
29296         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29297         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
29298         return ret_arr;
29299 }
29300
29301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29302         LDKInMemorySigner this_ptr_conv;
29303         this_ptr_conv.inner = untag_ptr(this_ptr);
29304         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29306         this_ptr_conv.is_owned = false;
29307         LDKSecretKey val_ref;
29308         CHECK((*env)->GetArrayLength(env, val) == 32);
29309         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
29310         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
29311 }
29312
29313 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
29314         LDKInMemorySigner this_ptr_conv;
29315         this_ptr_conv.inner = untag_ptr(this_ptr);
29316         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29318         this_ptr_conv.is_owned = false;
29319         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29320         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
29321         return ret_arr;
29322 }
29323
29324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29325         LDKInMemorySigner this_ptr_conv;
29326         this_ptr_conv.inner = untag_ptr(this_ptr);
29327         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29329         this_ptr_conv.is_owned = false;
29330         LDKSecretKey val_ref;
29331         CHECK((*env)->GetArrayLength(env, val) == 32);
29332         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
29333         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
29334 }
29335
29336 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
29337         LDKInMemorySigner this_ptr_conv;
29338         this_ptr_conv.inner = untag_ptr(this_ptr);
29339         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29341         this_ptr_conv.is_owned = false;
29342         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29343         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
29344         return ret_arr;
29345 }
29346
29347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29348         LDKInMemorySigner this_ptr_conv;
29349         this_ptr_conv.inner = untag_ptr(this_ptr);
29350         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29352         this_ptr_conv.is_owned = false;
29353         LDKSecretKey val_ref;
29354         CHECK((*env)->GetArrayLength(env, val) == 32);
29355         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
29356         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
29357 }
29358
29359 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
29360         LDKInMemorySigner this_ptr_conv;
29361         this_ptr_conv.inner = untag_ptr(this_ptr);
29362         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29364         this_ptr_conv.is_owned = false;
29365         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29366         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
29367         return ret_arr;
29368 }
29369
29370 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) {
29371         LDKInMemorySigner this_ptr_conv;
29372         this_ptr_conv.inner = untag_ptr(this_ptr);
29373         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29375         this_ptr_conv.is_owned = false;
29376         LDKSecretKey val_ref;
29377         CHECK((*env)->GetArrayLength(env, val) == 32);
29378         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
29379         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
29380 }
29381
29382 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
29383         LDKInMemorySigner this_ptr_conv;
29384         this_ptr_conv.inner = untag_ptr(this_ptr);
29385         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29387         this_ptr_conv.is_owned = false;
29388         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29389         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
29390         return ret_arr;
29391 }
29392
29393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29394         LDKInMemorySigner this_ptr_conv;
29395         this_ptr_conv.inner = untag_ptr(this_ptr);
29396         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29398         this_ptr_conv.is_owned = false;
29399         LDKSecretKey val_ref;
29400         CHECK((*env)->GetArrayLength(env, val) == 32);
29401         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
29402         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
29403 }
29404
29405 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
29406         LDKInMemorySigner this_ptr_conv;
29407         this_ptr_conv.inner = untag_ptr(this_ptr);
29408         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29410         this_ptr_conv.is_owned = false;
29411         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29412         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
29413         return ret_arr;
29414 }
29415
29416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29417         LDKInMemorySigner this_ptr_conv;
29418         this_ptr_conv.inner = untag_ptr(this_ptr);
29419         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29421         this_ptr_conv.is_owned = false;
29422         LDKThirtyTwoBytes val_ref;
29423         CHECK((*env)->GetArrayLength(env, val) == 32);
29424         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29425         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
29426 }
29427
29428 static inline uint64_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
29429         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
29430         int64_t ret_ref = 0;
29431         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29432         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29433         return ret_ref;
29434 }
29435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29436         LDKInMemorySigner arg_conv;
29437         arg_conv.inner = untag_ptr(arg);
29438         arg_conv.is_owned = ptr_is_owned(arg);
29439         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29440         arg_conv.is_owned = false;
29441         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
29442         return ret_conv;
29443 }
29444
29445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29446         LDKInMemorySigner orig_conv;
29447         orig_conv.inner = untag_ptr(orig);
29448         orig_conv.is_owned = ptr_is_owned(orig);
29449         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29450         orig_conv.is_owned = false;
29451         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
29452         int64_t ret_ref = 0;
29453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29454         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29455         return ret_ref;
29456 }
29457
29458 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) {
29459         LDKSecretKey node_secret_ref;
29460         CHECK((*env)->GetArrayLength(env, node_secret) == 32);
29461         (*env)->GetByteArrayRegion(env, node_secret, 0, 32, node_secret_ref.bytes);
29462         LDKSecretKey funding_key_ref;
29463         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
29464         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
29465         LDKSecretKey revocation_base_key_ref;
29466         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
29467         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
29468         LDKSecretKey payment_key_ref;
29469         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
29470         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
29471         LDKSecretKey delayed_payment_base_key_ref;
29472         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
29473         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
29474         LDKSecretKey htlc_base_key_ref;
29475         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
29476         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
29477         LDKThirtyTwoBytes commitment_seed_ref;
29478         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
29479         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
29480         LDKThirtyTwoBytes channel_keys_id_ref;
29481         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
29482         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
29483         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);
29484         int64_t ret_ref = 0;
29485         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29486         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29487         return ret_ref;
29488 }
29489
29490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
29491         LDKInMemorySigner this_arg_conv;
29492         this_arg_conv.inner = untag_ptr(this_arg);
29493         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29495         this_arg_conv.is_owned = false;
29496         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
29497         int64_t ret_ref = 0;
29498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29499         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29500         return ret_ref;
29501 }
29502
29503 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
29504         LDKInMemorySigner this_arg_conv;
29505         this_arg_conv.inner = untag_ptr(this_arg);
29506         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29508         this_arg_conv.is_owned = false;
29509         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
29510         return ret_conv;
29511 }
29512
29513 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
29514         LDKInMemorySigner this_arg_conv;
29515         this_arg_conv.inner = untag_ptr(this_arg);
29516         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29518         this_arg_conv.is_owned = false;
29519         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
29520         return ret_conv;
29521 }
29522
29523 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
29524         LDKInMemorySigner this_arg_conv;
29525         this_arg_conv.inner = untag_ptr(this_arg);
29526         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29528         this_arg_conv.is_owned = false;
29529         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
29530         return ret_conv;
29531 }
29532
29533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
29534         LDKInMemorySigner this_arg_conv;
29535         this_arg_conv.inner = untag_ptr(this_arg);
29536         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29538         this_arg_conv.is_owned = false;
29539         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
29540         int64_t ret_ref = 0;
29541         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29542         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29543         return ret_ref;
29544 }
29545
29546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
29547         LDKInMemorySigner this_arg_conv;
29548         this_arg_conv.inner = untag_ptr(this_arg);
29549         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29551         this_arg_conv.is_owned = false;
29552         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
29553         int64_t ret_ref = 0;
29554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29555         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29556         return ret_ref;
29557 }
29558
29559 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
29560         LDKInMemorySigner this_arg_conv;
29561         this_arg_conv.inner = untag_ptr(this_arg);
29562         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29564         this_arg_conv.is_owned = false;
29565         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
29566         return ret_conv;
29567 }
29568
29569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1sign_1counterparty_1payment_1input(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray spend_tx, int64_t input_idx, int64_t descriptor) {
29570         LDKInMemorySigner this_arg_conv;
29571         this_arg_conv.inner = untag_ptr(this_arg);
29572         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29574         this_arg_conv.is_owned = false;
29575         LDKTransaction spend_tx_ref;
29576         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
29577         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
29578         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
29579         spend_tx_ref.data_is_owned = true;
29580         LDKStaticPaymentOutputDescriptor descriptor_conv;
29581         descriptor_conv.inner = untag_ptr(descriptor);
29582         descriptor_conv.is_owned = ptr_is_owned(descriptor);
29583         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
29584         descriptor_conv.is_owned = false;
29585         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
29586         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
29587         return tag_ptr(ret_conv, true);
29588 }
29589
29590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1sign_1dynamic_1p2wsh_1input(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray spend_tx, int64_t input_idx, int64_t descriptor) {
29591         LDKInMemorySigner this_arg_conv;
29592         this_arg_conv.inner = untag_ptr(this_arg);
29593         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29595         this_arg_conv.is_owned = false;
29596         LDKTransaction spend_tx_ref;
29597         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
29598         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
29599         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
29600         spend_tx_ref.data_is_owned = true;
29601         LDKDelayedPaymentOutputDescriptor descriptor_conv;
29602         descriptor_conv.inner = untag_ptr(descriptor);
29603         descriptor_conv.is_owned = ptr_is_owned(descriptor);
29604         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
29605         descriptor_conv.is_owned = false;
29606         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
29607         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
29608         return tag_ptr(ret_conv, true);
29609 }
29610
29611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
29612         LDKInMemorySigner this_arg_conv;
29613         this_arg_conv.inner = untag_ptr(this_arg);
29614         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29616         this_arg_conv.is_owned = false;
29617         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
29618         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
29619         return tag_ptr(ret_ret, true);
29620 }
29621
29622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
29623         LDKInMemorySigner this_arg_conv;
29624         this_arg_conv.inner = untag_ptr(this_arg);
29625         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29627         this_arg_conv.is_owned = false;
29628         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
29629         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
29630         return tag_ptr(ret_ret, true);
29631 }
29632
29633 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
29634         LDKInMemorySigner obj_conv;
29635         obj_conv.inner = untag_ptr(obj);
29636         obj_conv.is_owned = ptr_is_owned(obj);
29637         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29638         obj_conv.is_owned = false;
29639         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
29640         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29641         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29642         CVec_u8Z_free(ret_var);
29643         return ret_arr;
29644 }
29645
29646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser, int8_tArray arg) {
29647         LDKu8slice ser_ref;
29648         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29649         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29650         LDKSecretKey arg_ref;
29651         CHECK((*env)->GetArrayLength(env, arg) == 32);
29652         (*env)->GetByteArrayRegion(env, arg, 0, 32, arg_ref.bytes);
29653         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
29654         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
29655         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29656         return tag_ptr(ret_conv, true);
29657 }
29658
29659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29660         LDKKeysManager this_obj_conv;
29661         this_obj_conv.inner = untag_ptr(this_obj);
29662         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29664         KeysManager_free(this_obj_conv);
29665 }
29666
29667 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) {
29668         unsigned char seed_arr[32];
29669         CHECK((*env)->GetArrayLength(env, seed) == 32);
29670         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
29671         unsigned char (*seed_ref)[32] = &seed_arr;
29672         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
29673         int64_t ret_ref = 0;
29674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29675         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29676         return ret_ref;
29677 }
29678
29679 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) {
29680         LDKKeysManager this_arg_conv;
29681         this_arg_conv.inner = untag_ptr(this_arg);
29682         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29684         this_arg_conv.is_owned = false;
29685         unsigned char params_arr[32];
29686         CHECK((*env)->GetArrayLength(env, params) == 32);
29687         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
29688         unsigned char (*params_ref)[32] = &params_arr;
29689         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
29690         int64_t ret_ref = 0;
29691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29692         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29693         return ret_ref;
29694 }
29695
29696 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) {
29697         LDKKeysManager this_arg_conv;
29698         this_arg_conv.inner = untag_ptr(this_arg);
29699         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29700         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29701         this_arg_conv.is_owned = false;
29702         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
29703         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
29704         if (descriptors_constr.datalen > 0)
29705                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
29706         else
29707                 descriptors_constr.data = NULL;
29708         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
29709         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
29710                 int64_t descriptors_conv_27 = descriptors_vals[b];
29711                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
29712                 CHECK_ACCESS(descriptors_conv_27_ptr);
29713                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
29714                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
29715                 descriptors_constr.data[b] = descriptors_conv_27_conv;
29716         }
29717         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
29718         LDKCVec_TxOutZ outputs_constr;
29719         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
29720         if (outputs_constr.datalen > 0)
29721                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
29722         else
29723                 outputs_constr.data = NULL;
29724         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
29725         for (size_t h = 0; h < outputs_constr.datalen; h++) {
29726                 int64_t outputs_conv_7 = outputs_vals[h];
29727                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
29728                 CHECK_ACCESS(outputs_conv_7_ptr);
29729                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
29730                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
29731                 outputs_constr.data[h] = outputs_conv_7_conv;
29732         }
29733         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
29734         LDKCVec_u8Z change_destination_script_ref;
29735         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
29736         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
29737         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
29738         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
29739         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
29740         return tag_ptr(ret_conv, true);
29741 }
29742
29743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
29744         LDKKeysManager this_arg_conv;
29745         this_arg_conv.inner = untag_ptr(this_arg);
29746         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29748         this_arg_conv.is_owned = false;
29749         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
29750         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
29751         return tag_ptr(ret_ret, true);
29752 }
29753
29754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29755         LDKPhantomKeysManager this_obj_conv;
29756         this_obj_conv.inner = untag_ptr(this_obj);
29757         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29759         PhantomKeysManager_free(this_obj_conv);
29760 }
29761
29762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
29763         LDKPhantomKeysManager this_arg_conv;
29764         this_arg_conv.inner = untag_ptr(this_arg);
29765         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29767         this_arg_conv.is_owned = false;
29768         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
29769         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
29770         return tag_ptr(ret_ret, true);
29771 }
29772
29773 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) {
29774         unsigned char seed_arr[32];
29775         CHECK((*env)->GetArrayLength(env, seed) == 32);
29776         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
29777         unsigned char (*seed_ref)[32] = &seed_arr;
29778         unsigned char cross_node_seed_arr[32];
29779         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
29780         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
29781         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
29782         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
29783         int64_t ret_ref = 0;
29784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29785         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29786         return ret_ref;
29787 }
29788
29789 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) {
29790         LDKPhantomKeysManager this_arg_conv;
29791         this_arg_conv.inner = untag_ptr(this_arg);
29792         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29794         this_arg_conv.is_owned = false;
29795         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
29796         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
29797         if (descriptors_constr.datalen > 0)
29798                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
29799         else
29800                 descriptors_constr.data = NULL;
29801         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
29802         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
29803                 int64_t descriptors_conv_27 = descriptors_vals[b];
29804                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
29805                 CHECK_ACCESS(descriptors_conv_27_ptr);
29806                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
29807                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
29808                 descriptors_constr.data[b] = descriptors_conv_27_conv;
29809         }
29810         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
29811         LDKCVec_TxOutZ outputs_constr;
29812         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
29813         if (outputs_constr.datalen > 0)
29814                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
29815         else
29816                 outputs_constr.data = NULL;
29817         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
29818         for (size_t h = 0; h < outputs_constr.datalen; h++) {
29819                 int64_t outputs_conv_7 = outputs_vals[h];
29820                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
29821                 CHECK_ACCESS(outputs_conv_7_ptr);
29822                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
29823                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
29824                 outputs_constr.data[h] = outputs_conv_7_conv;
29825         }
29826         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
29827         LDKCVec_u8Z change_destination_script_ref;
29828         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
29829         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
29830         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
29831         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
29832         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
29833         return tag_ptr(ret_conv, true);
29834 }
29835
29836 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) {
29837         LDKPhantomKeysManager this_arg_conv;
29838         this_arg_conv.inner = untag_ptr(this_arg);
29839         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29841         this_arg_conv.is_owned = false;
29842         unsigned char params_arr[32];
29843         CHECK((*env)->GetArrayLength(env, params) == 32);
29844         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
29845         unsigned char (*params_ref)[32] = &params_arr;
29846         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
29847         int64_t ret_ref = 0;
29848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29849         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29850         return ret_ref;
29851 }
29852
29853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29854         LDKChannelManager this_obj_conv;
29855         this_obj_conv.inner = untag_ptr(this_obj);
29856         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29858         ChannelManager_free(this_obj_conv);
29859 }
29860
29861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29862         LDKChainParameters this_obj_conv;
29863         this_obj_conv.inner = untag_ptr(this_obj);
29864         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29866         ChainParameters_free(this_obj_conv);
29867 }
29868
29869 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
29870         LDKChainParameters this_ptr_conv;
29871         this_ptr_conv.inner = untag_ptr(this_ptr);
29872         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29874         this_ptr_conv.is_owned = false;
29875         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
29876         return ret_conv;
29877 }
29878
29879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
29880         LDKChainParameters this_ptr_conv;
29881         this_ptr_conv.inner = untag_ptr(this_ptr);
29882         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29884         this_ptr_conv.is_owned = false;
29885         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
29886         ChainParameters_set_network(&this_ptr_conv, val_conv);
29887 }
29888
29889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
29890         LDKChainParameters this_ptr_conv;
29891         this_ptr_conv.inner = untag_ptr(this_ptr);
29892         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29894         this_ptr_conv.is_owned = false;
29895         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
29896         int64_t ret_ref = 0;
29897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29898         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29899         return ret_ref;
29900 }
29901
29902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29903         LDKChainParameters this_ptr_conv;
29904         this_ptr_conv.inner = untag_ptr(this_ptr);
29905         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29907         this_ptr_conv.is_owned = false;
29908         LDKBestBlock val_conv;
29909         val_conv.inner = untag_ptr(val);
29910         val_conv.is_owned = ptr_is_owned(val);
29911         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29912         val_conv = BestBlock_clone(&val_conv);
29913         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
29914 }
29915
29916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
29917         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
29918         LDKBestBlock best_block_arg_conv;
29919         best_block_arg_conv.inner = untag_ptr(best_block_arg);
29920         best_block_arg_conv.is_owned = ptr_is_owned(best_block_arg);
29921         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
29922         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
29923         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
29924         int64_t ret_ref = 0;
29925         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29926         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29927         return ret_ref;
29928 }
29929
29930 static inline uint64_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
29931         LDKChainParameters ret_var = ChainParameters_clone(arg);
29932         int64_t ret_ref = 0;
29933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29934         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29935         return ret_ref;
29936 }
29937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29938         LDKChainParameters arg_conv;
29939         arg_conv.inner = untag_ptr(arg);
29940         arg_conv.is_owned = ptr_is_owned(arg);
29941         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29942         arg_conv.is_owned = false;
29943         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
29944         return ret_conv;
29945 }
29946
29947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29948         LDKChainParameters orig_conv;
29949         orig_conv.inner = untag_ptr(orig);
29950         orig_conv.is_owned = ptr_is_owned(orig);
29951         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29952         orig_conv.is_owned = false;
29953         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
29954         int64_t ret_ref = 0;
29955         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29956         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29957         return ret_ref;
29958 }
29959
29960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29961         LDKCounterpartyForwardingInfo this_obj_conv;
29962         this_obj_conv.inner = untag_ptr(this_obj);
29963         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29965         CounterpartyForwardingInfo_free(this_obj_conv);
29966 }
29967
29968 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29969         LDKCounterpartyForwardingInfo this_ptr_conv;
29970         this_ptr_conv.inner = untag_ptr(this_ptr);
29971         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29973         this_ptr_conv.is_owned = false;
29974         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
29975         return ret_conv;
29976 }
29977
29978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29979         LDKCounterpartyForwardingInfo this_ptr_conv;
29980         this_ptr_conv.inner = untag_ptr(this_ptr);
29981         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29983         this_ptr_conv.is_owned = false;
29984         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
29985 }
29986
29987 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
29988         LDKCounterpartyForwardingInfo this_ptr_conv;
29989         this_ptr_conv.inner = untag_ptr(this_ptr);
29990         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29992         this_ptr_conv.is_owned = false;
29993         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
29994         return ret_conv;
29995 }
29996
29997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29998         LDKCounterpartyForwardingInfo this_ptr_conv;
29999         this_ptr_conv.inner = untag_ptr(this_ptr);
30000         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30002         this_ptr_conv.is_owned = false;
30003         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
30004 }
30005
30006 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
30007         LDKCounterpartyForwardingInfo this_ptr_conv;
30008         this_ptr_conv.inner = untag_ptr(this_ptr);
30009         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30011         this_ptr_conv.is_owned = false;
30012         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
30013         return ret_conv;
30014 }
30015
30016 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30017         LDKCounterpartyForwardingInfo this_ptr_conv;
30018         this_ptr_conv.inner = untag_ptr(this_ptr);
30019         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30020         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30021         this_ptr_conv.is_owned = false;
30022         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
30023 }
30024
30025 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) {
30026         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
30027         int64_t ret_ref = 0;
30028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30029         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30030         return ret_ref;
30031 }
30032
30033 static inline uint64_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
30034         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
30035         int64_t ret_ref = 0;
30036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30037         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30038         return ret_ref;
30039 }
30040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30041         LDKCounterpartyForwardingInfo arg_conv;
30042         arg_conv.inner = untag_ptr(arg);
30043         arg_conv.is_owned = ptr_is_owned(arg);
30044         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30045         arg_conv.is_owned = false;
30046         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
30047         return ret_conv;
30048 }
30049
30050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30051         LDKCounterpartyForwardingInfo orig_conv;
30052         orig_conv.inner = untag_ptr(orig);
30053         orig_conv.is_owned = ptr_is_owned(orig);
30054         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30055         orig_conv.is_owned = false;
30056         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
30057         int64_t ret_ref = 0;
30058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30059         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30060         return ret_ref;
30061 }
30062
30063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30064         LDKChannelCounterparty this_obj_conv;
30065         this_obj_conv.inner = untag_ptr(this_obj);
30066         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30068         ChannelCounterparty_free(this_obj_conv);
30069 }
30070
30071 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30072         LDKChannelCounterparty this_ptr_conv;
30073         this_ptr_conv.inner = untag_ptr(this_ptr);
30074         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30075         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30076         this_ptr_conv.is_owned = false;
30077         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30078         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
30079         return ret_arr;
30080 }
30081
30082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30083         LDKChannelCounterparty this_ptr_conv;
30084         this_ptr_conv.inner = untag_ptr(this_ptr);
30085         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30087         this_ptr_conv.is_owned = false;
30088         LDKPublicKey val_ref;
30089         CHECK((*env)->GetArrayLength(env, val) == 33);
30090         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30091         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
30092 }
30093
30094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
30095         LDKChannelCounterparty this_ptr_conv;
30096         this_ptr_conv.inner = untag_ptr(this_ptr);
30097         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30098         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30099         this_ptr_conv.is_owned = false;
30100         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
30101         int64_t ret_ref = 0;
30102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30103         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30104         return ret_ref;
30105 }
30106
30107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30108         LDKChannelCounterparty this_ptr_conv;
30109         this_ptr_conv.inner = untag_ptr(this_ptr);
30110         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30112         this_ptr_conv.is_owned = false;
30113         LDKInitFeatures val_conv;
30114         val_conv.inner = untag_ptr(val);
30115         val_conv.is_owned = ptr_is_owned(val);
30116         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30117         val_conv = InitFeatures_clone(&val_conv);
30118         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
30119 }
30120
30121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
30122         LDKChannelCounterparty this_ptr_conv;
30123         this_ptr_conv.inner = untag_ptr(this_ptr);
30124         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30126         this_ptr_conv.is_owned = false;
30127         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
30128         return ret_conv;
30129 }
30130
30131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30132         LDKChannelCounterparty this_ptr_conv;
30133         this_ptr_conv.inner = untag_ptr(this_ptr);
30134         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30136         this_ptr_conv.is_owned = false;
30137         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
30138 }
30139
30140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
30141         LDKChannelCounterparty this_ptr_conv;
30142         this_ptr_conv.inner = untag_ptr(this_ptr);
30143         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30145         this_ptr_conv.is_owned = false;
30146         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
30147         int64_t ret_ref = 0;
30148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30149         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30150         return ret_ref;
30151 }
30152
30153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30154         LDKChannelCounterparty this_ptr_conv;
30155         this_ptr_conv.inner = untag_ptr(this_ptr);
30156         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30158         this_ptr_conv.is_owned = false;
30159         LDKCounterpartyForwardingInfo val_conv;
30160         val_conv.inner = untag_ptr(val);
30161         val_conv.is_owned = ptr_is_owned(val);
30162         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30163         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
30164         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
30165 }
30166
30167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30168         LDKChannelCounterparty this_ptr_conv;
30169         this_ptr_conv.inner = untag_ptr(this_ptr);
30170         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30172         this_ptr_conv.is_owned = false;
30173         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30174         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
30175         int64_t ret_ref = tag_ptr(ret_copy, true);
30176         return ret_ref;
30177 }
30178
30179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30180         LDKChannelCounterparty this_ptr_conv;
30181         this_ptr_conv.inner = untag_ptr(this_ptr);
30182         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30184         this_ptr_conv.is_owned = false;
30185         void* val_ptr = untag_ptr(val);
30186         CHECK_ACCESS(val_ptr);
30187         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30188         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
30189         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
30190 }
30191
30192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30193         LDKChannelCounterparty this_ptr_conv;
30194         this_ptr_conv.inner = untag_ptr(this_ptr);
30195         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30197         this_ptr_conv.is_owned = false;
30198         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30199         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
30200         int64_t ret_ref = tag_ptr(ret_copy, true);
30201         return ret_ref;
30202 }
30203
30204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30205         LDKChannelCounterparty this_ptr_conv;
30206         this_ptr_conv.inner = untag_ptr(this_ptr);
30207         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30209         this_ptr_conv.is_owned = false;
30210         void* val_ptr = untag_ptr(val);
30211         CHECK_ACCESS(val_ptr);
30212         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30213         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
30214         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
30215 }
30216
30217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1new(JNIEnv *env, jclass clz, int8_tArray node_id_arg, int64_t features_arg, int64_t unspendable_punishment_reserve_arg, int64_t forwarding_info_arg, int64_t outbound_htlc_minimum_msat_arg, int64_t outbound_htlc_maximum_msat_arg) {
30218         LDKPublicKey node_id_arg_ref;
30219         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
30220         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
30221         LDKInitFeatures features_arg_conv;
30222         features_arg_conv.inner = untag_ptr(features_arg);
30223         features_arg_conv.is_owned = ptr_is_owned(features_arg);
30224         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
30225         features_arg_conv = InitFeatures_clone(&features_arg_conv);
30226         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
30227         forwarding_info_arg_conv.inner = untag_ptr(forwarding_info_arg);
30228         forwarding_info_arg_conv.is_owned = ptr_is_owned(forwarding_info_arg);
30229         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
30230         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
30231         void* outbound_htlc_minimum_msat_arg_ptr = untag_ptr(outbound_htlc_minimum_msat_arg);
30232         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
30233         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
30234         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_minimum_msat_arg));
30235         void* outbound_htlc_maximum_msat_arg_ptr = untag_ptr(outbound_htlc_maximum_msat_arg);
30236         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
30237         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
30238         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_maximum_msat_arg));
30239         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv, outbound_htlc_minimum_msat_arg_conv, outbound_htlc_maximum_msat_arg_conv);
30240         int64_t ret_ref = 0;
30241         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30242         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30243         return ret_ref;
30244 }
30245
30246 static inline uint64_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
30247         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
30248         int64_t ret_ref = 0;
30249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30250         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30251         return ret_ref;
30252 }
30253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30254         LDKChannelCounterparty arg_conv;
30255         arg_conv.inner = untag_ptr(arg);
30256         arg_conv.is_owned = ptr_is_owned(arg);
30257         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30258         arg_conv.is_owned = false;
30259         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
30260         return ret_conv;
30261 }
30262
30263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30264         LDKChannelCounterparty orig_conv;
30265         orig_conv.inner = untag_ptr(orig);
30266         orig_conv.is_owned = ptr_is_owned(orig);
30267         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30268         orig_conv.is_owned = false;
30269         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
30270         int64_t ret_ref = 0;
30271         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30272         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30273         return ret_ref;
30274 }
30275
30276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30277         LDKChannelDetails this_obj_conv;
30278         this_obj_conv.inner = untag_ptr(this_obj);
30279         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30281         ChannelDetails_free(this_obj_conv);
30282 }
30283
30284 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30285         LDKChannelDetails this_ptr_conv;
30286         this_ptr_conv.inner = untag_ptr(this_ptr);
30287         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30289         this_ptr_conv.is_owned = false;
30290         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30291         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
30292         return ret_arr;
30293 }
30294
30295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30296         LDKChannelDetails this_ptr_conv;
30297         this_ptr_conv.inner = untag_ptr(this_ptr);
30298         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30300         this_ptr_conv.is_owned = false;
30301         LDKThirtyTwoBytes val_ref;
30302         CHECK((*env)->GetArrayLength(env, val) == 32);
30303         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30304         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
30305 }
30306
30307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
30308         LDKChannelDetails this_ptr_conv;
30309         this_ptr_conv.inner = untag_ptr(this_ptr);
30310         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30312         this_ptr_conv.is_owned = false;
30313         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
30314         int64_t ret_ref = 0;
30315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30316         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30317         return ret_ref;
30318 }
30319
30320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30321         LDKChannelDetails this_ptr_conv;
30322         this_ptr_conv.inner = untag_ptr(this_ptr);
30323         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30325         this_ptr_conv.is_owned = false;
30326         LDKChannelCounterparty val_conv;
30327         val_conv.inner = untag_ptr(val);
30328         val_conv.is_owned = ptr_is_owned(val);
30329         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30330         val_conv = ChannelCounterparty_clone(&val_conv);
30331         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
30332 }
30333
30334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
30335         LDKChannelDetails this_ptr_conv;
30336         this_ptr_conv.inner = untag_ptr(this_ptr);
30337         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30339         this_ptr_conv.is_owned = false;
30340         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
30341         int64_t ret_ref = 0;
30342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30343         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30344         return ret_ref;
30345 }
30346
30347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30348         LDKChannelDetails this_ptr_conv;
30349         this_ptr_conv.inner = untag_ptr(this_ptr);
30350         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30352         this_ptr_conv.is_owned = false;
30353         LDKOutPoint val_conv;
30354         val_conv.inner = untag_ptr(val);
30355         val_conv.is_owned = ptr_is_owned(val);
30356         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30357         val_conv = OutPoint_clone(&val_conv);
30358         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
30359 }
30360
30361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
30362         LDKChannelDetails this_ptr_conv;
30363         this_ptr_conv.inner = untag_ptr(this_ptr);
30364         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30366         this_ptr_conv.is_owned = false;
30367         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
30368         int64_t ret_ref = 0;
30369         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30370         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30371         return ret_ref;
30372 }
30373
30374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30375         LDKChannelDetails this_ptr_conv;
30376         this_ptr_conv.inner = untag_ptr(this_ptr);
30377         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30379         this_ptr_conv.is_owned = false;
30380         LDKChannelTypeFeatures val_conv;
30381         val_conv.inner = untag_ptr(val);
30382         val_conv.is_owned = ptr_is_owned(val);
30383         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30384         val_conv = ChannelTypeFeatures_clone(&val_conv);
30385         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
30386 }
30387
30388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30389         LDKChannelDetails this_ptr_conv;
30390         this_ptr_conv.inner = untag_ptr(this_ptr);
30391         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30393         this_ptr_conv.is_owned = false;
30394         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30395         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
30396         int64_t ret_ref = tag_ptr(ret_copy, true);
30397         return ret_ref;
30398 }
30399
30400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30401         LDKChannelDetails this_ptr_conv;
30402         this_ptr_conv.inner = untag_ptr(this_ptr);
30403         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30405         this_ptr_conv.is_owned = false;
30406         void* val_ptr = untag_ptr(val);
30407         CHECK_ACCESS(val_ptr);
30408         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30409         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
30410         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
30411 }
30412
30413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
30414         LDKChannelDetails this_ptr_conv;
30415         this_ptr_conv.inner = untag_ptr(this_ptr);
30416         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30418         this_ptr_conv.is_owned = false;
30419         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30420         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
30421         int64_t ret_ref = tag_ptr(ret_copy, true);
30422         return ret_ref;
30423 }
30424
30425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30426         LDKChannelDetails this_ptr_conv;
30427         this_ptr_conv.inner = untag_ptr(this_ptr);
30428         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30430         this_ptr_conv.is_owned = false;
30431         void* val_ptr = untag_ptr(val);
30432         CHECK_ACCESS(val_ptr);
30433         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30434         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
30435         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
30436 }
30437
30438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
30439         LDKChannelDetails this_ptr_conv;
30440         this_ptr_conv.inner = untag_ptr(this_ptr);
30441         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30443         this_ptr_conv.is_owned = false;
30444         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30445         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
30446         int64_t ret_ref = tag_ptr(ret_copy, true);
30447         return ret_ref;
30448 }
30449
30450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30451         LDKChannelDetails this_ptr_conv;
30452         this_ptr_conv.inner = untag_ptr(this_ptr);
30453         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30455         this_ptr_conv.is_owned = false;
30456         void* val_ptr = untag_ptr(val);
30457         CHECK_ACCESS(val_ptr);
30458         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30459         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
30460         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
30461 }
30462
30463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30464         LDKChannelDetails this_ptr_conv;
30465         this_ptr_conv.inner = untag_ptr(this_ptr);
30466         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30468         this_ptr_conv.is_owned = false;
30469         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
30470         return ret_conv;
30471 }
30472
30473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30474         LDKChannelDetails this_ptr_conv;
30475         this_ptr_conv.inner = untag_ptr(this_ptr);
30476         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30478         this_ptr_conv.is_owned = false;
30479         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
30480 }
30481
30482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
30483         LDKChannelDetails this_ptr_conv;
30484         this_ptr_conv.inner = untag_ptr(this_ptr);
30485         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30487         this_ptr_conv.is_owned = false;
30488         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30489         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
30490         int64_t ret_ref = tag_ptr(ret_copy, true);
30491         return ret_ref;
30492 }
30493
30494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30495         LDKChannelDetails this_ptr_conv;
30496         this_ptr_conv.inner = untag_ptr(this_ptr);
30497         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30499         this_ptr_conv.is_owned = false;
30500         void* val_ptr = untag_ptr(val);
30501         CHECK_ACCESS(val_ptr);
30502         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30503         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
30504         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
30505 }
30506
30507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30508         LDKChannelDetails this_ptr_conv;
30509         this_ptr_conv.inner = untag_ptr(this_ptr);
30510         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30512         this_ptr_conv.is_owned = false;
30513         int64_t ret_conv = ChannelDetails_get_user_channel_id(&this_ptr_conv);
30514         return ret_conv;
30515 }
30516
30517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30518         LDKChannelDetails this_ptr_conv;
30519         this_ptr_conv.inner = untag_ptr(this_ptr);
30520         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30522         this_ptr_conv.is_owned = false;
30523         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
30524 }
30525
30526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30527         LDKChannelDetails this_ptr_conv;
30528         this_ptr_conv.inner = untag_ptr(this_ptr);
30529         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30531         this_ptr_conv.is_owned = false;
30532         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
30533         return ret_conv;
30534 }
30535
30536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30537         LDKChannelDetails this_ptr_conv;
30538         this_ptr_conv.inner = untag_ptr(this_ptr);
30539         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30541         this_ptr_conv.is_owned = false;
30542         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
30543 }
30544
30545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30546         LDKChannelDetails this_ptr_conv;
30547         this_ptr_conv.inner = untag_ptr(this_ptr);
30548         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30550         this_ptr_conv.is_owned = false;
30551         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
30552         return ret_conv;
30553 }
30554
30555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30556         LDKChannelDetails this_ptr_conv;
30557         this_ptr_conv.inner = untag_ptr(this_ptr);
30558         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30560         this_ptr_conv.is_owned = false;
30561         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
30562 }
30563
30564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30565         LDKChannelDetails this_ptr_conv;
30566         this_ptr_conv.inner = untag_ptr(this_ptr);
30567         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30569         this_ptr_conv.is_owned = false;
30570         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
30571         return ret_conv;
30572 }
30573
30574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30575         LDKChannelDetails this_ptr_conv;
30576         this_ptr_conv.inner = untag_ptr(this_ptr);
30577         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30579         this_ptr_conv.is_owned = false;
30580         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
30581 }
30582
30583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30584         LDKChannelDetails this_ptr_conv;
30585         this_ptr_conv.inner = untag_ptr(this_ptr);
30586         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30588         this_ptr_conv.is_owned = false;
30589         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
30590         return ret_conv;
30591 }
30592
30593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30594         LDKChannelDetails this_ptr_conv;
30595         this_ptr_conv.inner = untag_ptr(this_ptr);
30596         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30598         this_ptr_conv.is_owned = false;
30599         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
30600 }
30601
30602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
30603         LDKChannelDetails this_ptr_conv;
30604         this_ptr_conv.inner = untag_ptr(this_ptr);
30605         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30607         this_ptr_conv.is_owned = false;
30608         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
30609         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
30610         int64_t ret_ref = tag_ptr(ret_copy, true);
30611         return ret_ref;
30612 }
30613
30614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30615         LDKChannelDetails this_ptr_conv;
30616         this_ptr_conv.inner = untag_ptr(this_ptr);
30617         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30619         this_ptr_conv.is_owned = false;
30620         void* val_ptr = untag_ptr(val);
30621         CHECK_ACCESS(val_ptr);
30622         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
30623         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
30624         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
30625 }
30626
30627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
30628         LDKChannelDetails this_ptr_conv;
30629         this_ptr_conv.inner = untag_ptr(this_ptr);
30630         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30632         this_ptr_conv.is_owned = false;
30633         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
30634         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
30635         int64_t ret_ref = tag_ptr(ret_copy, true);
30636         return ret_ref;
30637 }
30638
30639 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) {
30640         LDKChannelDetails this_ptr_conv;
30641         this_ptr_conv.inner = untag_ptr(this_ptr);
30642         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30644         this_ptr_conv.is_owned = false;
30645         void* val_ptr = untag_ptr(val);
30646         CHECK_ACCESS(val_ptr);
30647         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
30648         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(val));
30649         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
30650 }
30651
30652 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
30653         LDKChannelDetails this_ptr_conv;
30654         this_ptr_conv.inner = untag_ptr(this_ptr);
30655         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30657         this_ptr_conv.is_owned = false;
30658         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
30659         return ret_conv;
30660 }
30661
30662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
30663         LDKChannelDetails this_ptr_conv;
30664         this_ptr_conv.inner = untag_ptr(this_ptr);
30665         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30667         this_ptr_conv.is_owned = false;
30668         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
30669 }
30670
30671 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr) {
30672         LDKChannelDetails this_ptr_conv;
30673         this_ptr_conv.inner = untag_ptr(this_ptr);
30674         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30676         this_ptr_conv.is_owned = false;
30677         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
30678         return ret_conv;
30679 }
30680
30681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
30682         LDKChannelDetails this_ptr_conv;
30683         this_ptr_conv.inner = untag_ptr(this_ptr);
30684         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30686         this_ptr_conv.is_owned = false;
30687         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
30688 }
30689
30690 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
30691         LDKChannelDetails this_ptr_conv;
30692         this_ptr_conv.inner = untag_ptr(this_ptr);
30693         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30695         this_ptr_conv.is_owned = false;
30696         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
30697         return ret_conv;
30698 }
30699
30700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
30701         LDKChannelDetails this_ptr_conv;
30702         this_ptr_conv.inner = untag_ptr(this_ptr);
30703         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30705         this_ptr_conv.is_owned = false;
30706         ChannelDetails_set_is_usable(&this_ptr_conv, val);
30707 }
30708
30709 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
30710         LDKChannelDetails this_ptr_conv;
30711         this_ptr_conv.inner = untag_ptr(this_ptr);
30712         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30714         this_ptr_conv.is_owned = false;
30715         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
30716         return ret_conv;
30717 }
30718
30719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
30720         LDKChannelDetails this_ptr_conv;
30721         this_ptr_conv.inner = untag_ptr(this_ptr);
30722         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30724         this_ptr_conv.is_owned = false;
30725         ChannelDetails_set_is_public(&this_ptr_conv, val);
30726 }
30727
30728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30729         LDKChannelDetails this_ptr_conv;
30730         this_ptr_conv.inner = untag_ptr(this_ptr);
30731         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30733         this_ptr_conv.is_owned = false;
30734         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30735         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
30736         int64_t ret_ref = tag_ptr(ret_copy, true);
30737         return ret_ref;
30738 }
30739
30740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30741         LDKChannelDetails this_ptr_conv;
30742         this_ptr_conv.inner = untag_ptr(this_ptr);
30743         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30745         this_ptr_conv.is_owned = false;
30746         void* val_ptr = untag_ptr(val);
30747         CHECK_ACCESS(val_ptr);
30748         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30749         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
30750         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
30751 }
30752
30753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
30754         LDKChannelDetails this_ptr_conv;
30755         this_ptr_conv.inner = untag_ptr(this_ptr);
30756         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30758         this_ptr_conv.is_owned = false;
30759         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30760         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
30761         int64_t ret_ref = tag_ptr(ret_copy, true);
30762         return ret_ref;
30763 }
30764
30765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30766         LDKChannelDetails this_ptr_conv;
30767         this_ptr_conv.inner = untag_ptr(this_ptr);
30768         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30770         this_ptr_conv.is_owned = false;
30771         void* val_ptr = untag_ptr(val);
30772         CHECK_ACCESS(val_ptr);
30773         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
30774         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
30775         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
30776 }
30777
30778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
30779         LDKChannelDetails this_ptr_conv;
30780         this_ptr_conv.inner = untag_ptr(this_ptr);
30781         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30783         this_ptr_conv.is_owned = false;
30784         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
30785         int64_t ret_ref = 0;
30786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30787         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30788         return ret_ref;
30789 }
30790
30791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30792         LDKChannelDetails this_ptr_conv;
30793         this_ptr_conv.inner = untag_ptr(this_ptr);
30794         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30796         this_ptr_conv.is_owned = false;
30797         LDKChannelConfig val_conv;
30798         val_conv.inner = untag_ptr(val);
30799         val_conv.is_owned = ptr_is_owned(val);
30800         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30801         val_conv = ChannelConfig_clone(&val_conv);
30802         ChannelDetails_set_config(&this_ptr_conv, val_conv);
30803 }
30804
30805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int64_t counterparty_arg, int64_t funding_txo_arg, int64_t channel_type_arg, int64_t short_channel_id_arg, int64_t outbound_scid_alias_arg, int64_t inbound_scid_alias_arg, int64_t channel_value_satoshis_arg, int64_t unspendable_punishment_reserve_arg, int64_t user_channel_id_arg, int64_t balance_msat_arg, int64_t outbound_capacity_msat_arg, int64_t next_outbound_htlc_limit_msat_arg, int64_t inbound_capacity_msat_arg, int64_t confirmations_required_arg, int64_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_channel_ready_arg, jboolean is_usable_arg, jboolean is_public_arg, int64_t inbound_htlc_minimum_msat_arg, int64_t inbound_htlc_maximum_msat_arg, int64_t config_arg) {
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         LDKChannelCounterparty counterparty_arg_conv;
30810         counterparty_arg_conv.inner = untag_ptr(counterparty_arg);
30811         counterparty_arg_conv.is_owned = ptr_is_owned(counterparty_arg);
30812         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
30813         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
30814         LDKOutPoint funding_txo_arg_conv;
30815         funding_txo_arg_conv.inner = untag_ptr(funding_txo_arg);
30816         funding_txo_arg_conv.is_owned = ptr_is_owned(funding_txo_arg);
30817         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
30818         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
30819         LDKChannelTypeFeatures channel_type_arg_conv;
30820         channel_type_arg_conv.inner = untag_ptr(channel_type_arg);
30821         channel_type_arg_conv.is_owned = ptr_is_owned(channel_type_arg);
30822         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
30823         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
30824         void* short_channel_id_arg_ptr = untag_ptr(short_channel_id_arg);
30825         CHECK_ACCESS(short_channel_id_arg_ptr);
30826         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
30827         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_arg));
30828         void* outbound_scid_alias_arg_ptr = untag_ptr(outbound_scid_alias_arg);
30829         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
30830         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
30831         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_scid_alias_arg));
30832         void* inbound_scid_alias_arg_ptr = untag_ptr(inbound_scid_alias_arg);
30833         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
30834         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
30835         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_scid_alias_arg));
30836         void* unspendable_punishment_reserve_arg_ptr = untag_ptr(unspendable_punishment_reserve_arg);
30837         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
30838         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
30839         void* confirmations_required_arg_ptr = untag_ptr(confirmations_required_arg);
30840         CHECK_ACCESS(confirmations_required_arg_ptr);
30841         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
30842         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_required_arg));
30843         void* force_close_spend_delay_arg_ptr = untag_ptr(force_close_spend_delay_arg);
30844         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
30845         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
30846         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(force_close_spend_delay_arg));
30847         void* inbound_htlc_minimum_msat_arg_ptr = untag_ptr(inbound_htlc_minimum_msat_arg);
30848         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
30849         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
30850         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_minimum_msat_arg));
30851         void* inbound_htlc_maximum_msat_arg_ptr = untag_ptr(inbound_htlc_maximum_msat_arg);
30852         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
30853         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
30854         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_maximum_msat_arg));
30855         LDKChannelConfig config_arg_conv;
30856         config_arg_conv.inner = untag_ptr(config_arg);
30857         config_arg_conv.is_owned = ptr_is_owned(config_arg);
30858         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
30859         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
30860         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, channel_type_arg_conv, short_channel_id_arg_conv, outbound_scid_alias_arg_conv, inbound_scid_alias_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_channel_id_arg, balance_msat_arg, outbound_capacity_msat_arg, next_outbound_htlc_limit_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_channel_ready_arg, is_usable_arg, is_public_arg, inbound_htlc_minimum_msat_arg_conv, inbound_htlc_maximum_msat_arg_conv, config_arg_conv);
30861         int64_t ret_ref = 0;
30862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30863         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30864         return ret_ref;
30865 }
30866
30867 static inline uint64_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
30868         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
30869         int64_t ret_ref = 0;
30870         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30871         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30872         return ret_ref;
30873 }
30874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30875         LDKChannelDetails arg_conv;
30876         arg_conv.inner = untag_ptr(arg);
30877         arg_conv.is_owned = ptr_is_owned(arg);
30878         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30879         arg_conv.is_owned = false;
30880         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
30881         return ret_conv;
30882 }
30883
30884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30885         LDKChannelDetails orig_conv;
30886         orig_conv.inner = untag_ptr(orig);
30887         orig_conv.is_owned = ptr_is_owned(orig);
30888         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30889         orig_conv.is_owned = false;
30890         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
30891         int64_t ret_ref = 0;
30892         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30893         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30894         return ret_ref;
30895 }
30896
30897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
30898         LDKChannelDetails this_arg_conv;
30899         this_arg_conv.inner = untag_ptr(this_arg);
30900         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30902         this_arg_conv.is_owned = false;
30903         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30904         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
30905         int64_t ret_ref = tag_ptr(ret_copy, true);
30906         return ret_ref;
30907 }
30908
30909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
30910         LDKChannelDetails this_arg_conv;
30911         this_arg_conv.inner = untag_ptr(this_arg);
30912         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30914         this_arg_conv.is_owned = false;
30915         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
30916         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
30917         int64_t ret_ref = tag_ptr(ret_copy, true);
30918         return ret_ref;
30919 }
30920
30921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30922         if (!ptr_is_owned(this_ptr)) return;
30923         void* this_ptr_ptr = untag_ptr(this_ptr);
30924         CHECK_ACCESS(this_ptr_ptr);
30925         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
30926         FREE(untag_ptr(this_ptr));
30927         PaymentSendFailure_free(this_ptr_conv);
30928 }
30929
30930 static inline uint64_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
30931         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30932         *ret_copy = PaymentSendFailure_clone(arg);
30933         int64_t ret_ref = tag_ptr(ret_copy, true);
30934         return ret_ref;
30935 }
30936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30937         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)untag_ptr(arg);
30938         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
30939         return ret_conv;
30940 }
30941
30942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30943         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)untag_ptr(orig);
30944         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30945         *ret_copy = PaymentSendFailure_clone(orig_conv);
30946         int64_t ret_ref = tag_ptr(ret_copy, true);
30947         return ret_ref;
30948 }
30949
30950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
30951         void* a_ptr = untag_ptr(a);
30952         CHECK_ACCESS(a_ptr);
30953         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
30954         a_conv = APIError_clone((LDKAPIError*)untag_ptr(a));
30955         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30956         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
30957         int64_t ret_ref = tag_ptr(ret_copy, true);
30958         return ret_ref;
30959 }
30960
30961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
30962         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
30963         a_constr.datalen = (*env)->GetArrayLength(env, a);
30964         if (a_constr.datalen > 0)
30965                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
30966         else
30967                 a_constr.data = NULL;
30968         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
30969         for (size_t w = 0; w < a_constr.datalen; w++) {
30970                 int64_t a_conv_22 = a_vals[w];
30971                 void* a_conv_22_ptr = untag_ptr(a_conv_22);
30972                 CHECK_ACCESS(a_conv_22_ptr);
30973                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
30974                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)untag_ptr(a_conv_22));
30975                 a_constr.data[w] = a_conv_22_conv;
30976         }
30977         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
30978         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
30979         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
30980         int64_t ret_ref = tag_ptr(ret_copy, true);
30981         return ret_ref;
30982 }
30983
30984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
30985         LDKCVec_APIErrorZ a_constr;
30986         a_constr.datalen = (*env)->GetArrayLength(env, a);
30987         if (a_constr.datalen > 0)
30988                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
30989         else
30990                 a_constr.data = NULL;
30991         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
30992         for (size_t k = 0; k < a_constr.datalen; k++) {
30993                 int64_t a_conv_10 = a_vals[k];
30994                 void* a_conv_10_ptr = untag_ptr(a_conv_10);
30995                 CHECK_ACCESS(a_conv_10_ptr);
30996                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
30997                 a_conv_10_conv = APIError_clone((LDKAPIError*)untag_ptr(a_conv_10));
30998                 a_constr.data[k] = a_conv_10_conv;
30999         }
31000         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
31001         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
31002         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
31003         int64_t ret_ref = tag_ptr(ret_copy, true);
31004         return ret_ref;
31005 }
31006
31007 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) {
31008         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
31009         results_constr.datalen = (*env)->GetArrayLength(env, results);
31010         if (results_constr.datalen > 0)
31011                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
31012         else
31013                 results_constr.data = NULL;
31014         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
31015         for (size_t w = 0; w < results_constr.datalen; w++) {
31016                 int64_t results_conv_22 = results_vals[w];
31017                 void* results_conv_22_ptr = untag_ptr(results_conv_22);
31018                 CHECK_ACCESS(results_conv_22_ptr);
31019                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
31020                 results_constr.data[w] = results_conv_22_conv;
31021         }
31022         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
31023         LDKRouteParameters failed_paths_retry_conv;
31024         failed_paths_retry_conv.inner = untag_ptr(failed_paths_retry);
31025         failed_paths_retry_conv.is_owned = ptr_is_owned(failed_paths_retry);
31026         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
31027         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
31028         LDKThirtyTwoBytes payment_id_ref;
31029         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
31030         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
31031         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
31032         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
31033         int64_t ret_ref = tag_ptr(ret_copy, true);
31034         return ret_ref;
31035 }
31036
31037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31038         LDKPhantomRouteHints this_obj_conv;
31039         this_obj_conv.inner = untag_ptr(this_obj);
31040         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31042         PhantomRouteHints_free(this_obj_conv);
31043 }
31044
31045 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
31046         LDKPhantomRouteHints this_ptr_conv;
31047         this_ptr_conv.inner = untag_ptr(this_ptr);
31048         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31050         this_ptr_conv.is_owned = false;
31051         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
31052         int64_tArray ret_arr = NULL;
31053         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
31054         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
31055         for (size_t q = 0; q < ret_var.datalen; q++) {
31056                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
31057                 int64_t ret_conv_16_ref = 0;
31058                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
31059                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
31060                 ret_arr_ptr[q] = ret_conv_16_ref;
31061         }
31062         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
31063         FREE(ret_var.data);
31064         return ret_arr;
31065 }
31066
31067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
31068         LDKPhantomRouteHints this_ptr_conv;
31069         this_ptr_conv.inner = untag_ptr(this_ptr);
31070         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31072         this_ptr_conv.is_owned = false;
31073         LDKCVec_ChannelDetailsZ val_constr;
31074         val_constr.datalen = (*env)->GetArrayLength(env, val);
31075         if (val_constr.datalen > 0)
31076                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
31077         else
31078                 val_constr.data = NULL;
31079         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
31080         for (size_t q = 0; q < val_constr.datalen; q++) {
31081                 int64_t val_conv_16 = val_vals[q];
31082                 LDKChannelDetails val_conv_16_conv;
31083                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
31084                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
31085                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
31086                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
31087                 val_constr.data[q] = val_conv_16_conv;
31088         }
31089         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
31090         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
31091 }
31092
31093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
31094         LDKPhantomRouteHints this_ptr_conv;
31095         this_ptr_conv.inner = untag_ptr(this_ptr);
31096         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31098         this_ptr_conv.is_owned = false;
31099         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
31100         return ret_conv;
31101 }
31102
31103 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31104         LDKPhantomRouteHints this_ptr_conv;
31105         this_ptr_conv.inner = untag_ptr(this_ptr);
31106         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31108         this_ptr_conv.is_owned = false;
31109         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
31110 }
31111
31112 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
31113         LDKPhantomRouteHints this_ptr_conv;
31114         this_ptr_conv.inner = untag_ptr(this_ptr);
31115         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31117         this_ptr_conv.is_owned = false;
31118         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31119         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
31120         return ret_arr;
31121 }
31122
31123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31124         LDKPhantomRouteHints this_ptr_conv;
31125         this_ptr_conv.inner = untag_ptr(this_ptr);
31126         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31128         this_ptr_conv.is_owned = false;
31129         LDKPublicKey val_ref;
31130         CHECK((*env)->GetArrayLength(env, val) == 33);
31131         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31132         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
31133 }
31134
31135 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) {
31136         LDKCVec_ChannelDetailsZ channels_arg_constr;
31137         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
31138         if (channels_arg_constr.datalen > 0)
31139                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
31140         else
31141                 channels_arg_constr.data = NULL;
31142         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
31143         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
31144                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
31145                 LDKChannelDetails channels_arg_conv_16_conv;
31146                 channels_arg_conv_16_conv.inner = untag_ptr(channels_arg_conv_16);
31147                 channels_arg_conv_16_conv.is_owned = ptr_is_owned(channels_arg_conv_16);
31148                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
31149                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
31150                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
31151         }
31152         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
31153         LDKPublicKey real_node_pubkey_arg_ref;
31154         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
31155         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
31156         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
31157         int64_t ret_ref = 0;
31158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31159         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31160         return ret_ref;
31161 }
31162
31163 static inline uint64_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
31164         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
31165         int64_t ret_ref = 0;
31166         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31167         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31168         return ret_ref;
31169 }
31170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31171         LDKPhantomRouteHints arg_conv;
31172         arg_conv.inner = untag_ptr(arg);
31173         arg_conv.is_owned = ptr_is_owned(arg);
31174         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31175         arg_conv.is_owned = false;
31176         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
31177         return ret_conv;
31178 }
31179
31180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31181         LDKPhantomRouteHints orig_conv;
31182         orig_conv.inner = untag_ptr(orig);
31183         orig_conv.is_owned = ptr_is_owned(orig);
31184         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31185         orig_conv.is_owned = false;
31186         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
31187         int64_t ret_ref = 0;
31188         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31189         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31190         return ret_ref;
31191 }
31192
31193 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) {
31194         void* fee_est_ptr = untag_ptr(fee_est);
31195         CHECK_ACCESS(fee_est_ptr);
31196         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
31197         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
31198                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31199                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
31200         }
31201         void* chain_monitor_ptr = untag_ptr(chain_monitor);
31202         CHECK_ACCESS(chain_monitor_ptr);
31203         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
31204         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
31205                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31206                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
31207         }
31208         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
31209         CHECK_ACCESS(tx_broadcaster_ptr);
31210         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
31211         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
31212                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31213                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
31214         }
31215         void* logger_ptr = untag_ptr(logger);
31216         CHECK_ACCESS(logger_ptr);
31217         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
31218         if (logger_conv.free == LDKLogger_JCalls_free) {
31219                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31220                 LDKLogger_JCalls_cloned(&logger_conv);
31221         }
31222         void* keys_manager_ptr = untag_ptr(keys_manager);
31223         CHECK_ACCESS(keys_manager_ptr);
31224         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
31225         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
31226                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31227                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
31228         }
31229         LDKUserConfig config_conv;
31230         config_conv.inner = untag_ptr(config);
31231         config_conv.is_owned = ptr_is_owned(config);
31232         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
31233         config_conv = UserConfig_clone(&config_conv);
31234         LDKChainParameters params_conv;
31235         params_conv.inner = untag_ptr(params);
31236         params_conv.is_owned = ptr_is_owned(params);
31237         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
31238         params_conv = ChainParameters_clone(&params_conv);
31239         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
31240         int64_t ret_ref = 0;
31241         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31242         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31243         return ret_ref;
31244 }
31245
31246 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
31247         LDKChannelManager this_arg_conv;
31248         this_arg_conv.inner = untag_ptr(this_arg);
31249         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31251         this_arg_conv.is_owned = false;
31252         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
31253         int64_t ret_ref = 0;
31254         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31255         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31256         return ret_ref;
31257 }
31258
31259 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) {
31260         LDKChannelManager this_arg_conv;
31261         this_arg_conv.inner = untag_ptr(this_arg);
31262         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31264         this_arg_conv.is_owned = false;
31265         LDKPublicKey their_network_key_ref;
31266         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
31267         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
31268         LDKUserConfig override_config_conv;
31269         override_config_conv.inner = untag_ptr(override_config);
31270         override_config_conv.is_owned = ptr_is_owned(override_config);
31271         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
31272         override_config_conv = UserConfig_clone(&override_config_conv);
31273         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
31274         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
31275         return tag_ptr(ret_conv, true);
31276 }
31277
31278 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
31279         LDKChannelManager this_arg_conv;
31280         this_arg_conv.inner = untag_ptr(this_arg);
31281         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31283         this_arg_conv.is_owned = false;
31284         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
31285         int64_tArray ret_arr = NULL;
31286         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
31287         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
31288         for (size_t q = 0; q < ret_var.datalen; q++) {
31289                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
31290                 int64_t ret_conv_16_ref = 0;
31291                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
31292                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
31293                 ret_arr_ptr[q] = ret_conv_16_ref;
31294         }
31295         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
31296         FREE(ret_var.data);
31297         return ret_arr;
31298 }
31299
31300 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
31301         LDKChannelManager this_arg_conv;
31302         this_arg_conv.inner = untag_ptr(this_arg);
31303         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31305         this_arg_conv.is_owned = false;
31306         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
31307         int64_tArray ret_arr = NULL;
31308         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
31309         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
31310         for (size_t q = 0; q < ret_var.datalen; q++) {
31311                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
31312                 int64_t ret_conv_16_ref = 0;
31313                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
31314                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
31315                 ret_arr_ptr[q] = ret_conv_16_ref;
31316         }
31317         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
31318         FREE(ret_var.data);
31319         return ret_arr;
31320 }
31321
31322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
31323         LDKChannelManager this_arg_conv;
31324         this_arg_conv.inner = untag_ptr(this_arg);
31325         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31327         this_arg_conv.is_owned = false;
31328         unsigned char channel_id_arr[32];
31329         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
31330         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
31331         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
31332         LDKPublicKey counterparty_node_id_ref;
31333         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31334         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31335         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31336         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
31337         return tag_ptr(ret_conv, true);
31338 }
31339
31340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel_1with_1target_1feerate(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id, int32_t target_feerate_sats_per_1000_weight) {
31341         LDKChannelManager this_arg_conv;
31342         this_arg_conv.inner = untag_ptr(this_arg);
31343         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31345         this_arg_conv.is_owned = false;
31346         unsigned char channel_id_arr[32];
31347         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
31348         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
31349         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
31350         LDKPublicKey counterparty_node_id_ref;
31351         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31352         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31353         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31354         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
31355         return tag_ptr(ret_conv, true);
31356 }
31357
31358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
31359         LDKChannelManager this_arg_conv;
31360         this_arg_conv.inner = untag_ptr(this_arg);
31361         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31363         this_arg_conv.is_owned = false;
31364         unsigned char channel_id_arr[32];
31365         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
31366         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
31367         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
31368         LDKPublicKey counterparty_node_id_ref;
31369         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31370         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31371         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31372         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
31373         return tag_ptr(ret_conv, true);
31374 }
31375
31376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id, int8_tArray counterparty_node_id) {
31377         LDKChannelManager this_arg_conv;
31378         this_arg_conv.inner = untag_ptr(this_arg);
31379         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31381         this_arg_conv.is_owned = false;
31382         unsigned char channel_id_arr[32];
31383         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
31384         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
31385         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
31386         LDKPublicKey counterparty_node_id_ref;
31387         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31388         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31389         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31390         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
31391         return tag_ptr(ret_conv, true);
31392 }
31393
31394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
31395         LDKChannelManager this_arg_conv;
31396         this_arg_conv.inner = untag_ptr(this_arg);
31397         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31399         this_arg_conv.is_owned = false;
31400         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
31401 }
31402
31403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
31404         LDKChannelManager this_arg_conv;
31405         this_arg_conv.inner = untag_ptr(this_arg);
31406         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31408         this_arg_conv.is_owned = false;
31409         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
31410 }
31411
31412 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) {
31413         LDKChannelManager this_arg_conv;
31414         this_arg_conv.inner = untag_ptr(this_arg);
31415         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31417         this_arg_conv.is_owned = false;
31418         LDKRoute route_conv;
31419         route_conv.inner = untag_ptr(route);
31420         route_conv.is_owned = ptr_is_owned(route);
31421         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
31422         route_conv.is_owned = false;
31423         LDKThirtyTwoBytes payment_hash_ref;
31424         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31425         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31426         LDKThirtyTwoBytes payment_secret_ref;
31427         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
31428         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
31429         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
31430         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
31431         return tag_ptr(ret_conv, true);
31432 }
31433
31434 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) {
31435         LDKChannelManager this_arg_conv;
31436         this_arg_conv.inner = untag_ptr(this_arg);
31437         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31439         this_arg_conv.is_owned = false;
31440         LDKRoute route_conv;
31441         route_conv.inner = untag_ptr(route);
31442         route_conv.is_owned = ptr_is_owned(route);
31443         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
31444         route_conv.is_owned = false;
31445         LDKThirtyTwoBytes payment_id_ref;
31446         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
31447         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
31448         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
31449         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
31450         return tag_ptr(ret_conv, true);
31451 }
31452
31453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
31454         LDKChannelManager this_arg_conv;
31455         this_arg_conv.inner = untag_ptr(this_arg);
31456         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31458         this_arg_conv.is_owned = false;
31459         LDKThirtyTwoBytes payment_id_ref;
31460         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
31461         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
31462         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
31463 }
31464
31465 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) {
31466         LDKChannelManager this_arg_conv;
31467         this_arg_conv.inner = untag_ptr(this_arg);
31468         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31470         this_arg_conv.is_owned = false;
31471         LDKRoute route_conv;
31472         route_conv.inner = untag_ptr(route);
31473         route_conv.is_owned = ptr_is_owned(route);
31474         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
31475         route_conv.is_owned = false;
31476         LDKThirtyTwoBytes payment_preimage_ref;
31477         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
31478         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
31479         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
31480         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
31481         return tag_ptr(ret_conv, true);
31482 }
31483
31484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1probe(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray hops) {
31485         LDKChannelManager this_arg_conv;
31486         this_arg_conv.inner = untag_ptr(this_arg);
31487         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31489         this_arg_conv.is_owned = false;
31490         LDKCVec_RouteHopZ hops_constr;
31491         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
31492         if (hops_constr.datalen > 0)
31493                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
31494         else
31495                 hops_constr.data = NULL;
31496         int64_t* hops_vals = (*env)->GetLongArrayElements (env, hops, NULL);
31497         for (size_t k = 0; k < hops_constr.datalen; k++) {
31498                 int64_t hops_conv_10 = hops_vals[k];
31499                 LDKRouteHop hops_conv_10_conv;
31500                 hops_conv_10_conv.inner = untag_ptr(hops_conv_10);
31501                 hops_conv_10_conv.is_owned = ptr_is_owned(hops_conv_10);
31502                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv_10_conv);
31503                 hops_conv_10_conv = RouteHop_clone(&hops_conv_10_conv);
31504                 hops_constr.data[k] = hops_conv_10_conv;
31505         }
31506         (*env)->ReleaseLongArrayElements(env, hops, hops_vals, 0);
31507         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
31508         *ret_conv = ChannelManager_send_probe(&this_arg_conv, hops_constr);
31509         return tag_ptr(ret_conv, true);
31510 }
31511
31512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1funding_1transaction_1generated(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int8_tArray funding_transaction) {
31513         LDKChannelManager this_arg_conv;
31514         this_arg_conv.inner = untag_ptr(this_arg);
31515         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31517         this_arg_conv.is_owned = false;
31518         unsigned char temporary_channel_id_arr[32];
31519         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
31520         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
31521         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
31522         LDKPublicKey counterparty_node_id_ref;
31523         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31524         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31525         LDKTransaction funding_transaction_ref;
31526         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
31527         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
31528         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
31529         funding_transaction_ref.data_is_owned = true;
31530         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31531         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
31532         return tag_ptr(ret_conv, true);
31533 }
31534
31535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1update_1channel_1config(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray counterparty_node_id, jobjectArray channel_ids, int64_t config) {
31536         LDKChannelManager this_arg_conv;
31537         this_arg_conv.inner = untag_ptr(this_arg);
31538         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31540         this_arg_conv.is_owned = false;
31541         LDKPublicKey counterparty_node_id_ref;
31542         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31543         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31544         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
31545         channel_ids_constr.datalen = (*env)->GetArrayLength(env, channel_ids);
31546         if (channel_ids_constr.datalen > 0)
31547                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
31548         else
31549                 channel_ids_constr.data = NULL;
31550         for (size_t i = 0; i < channel_ids_constr.datalen; i++) {
31551                 int8_tArray channel_ids_conv_8 = (*env)->GetObjectArrayElement(env, channel_ids, i);
31552                 LDKThirtyTwoBytes channel_ids_conv_8_ref;
31553                 CHECK((*env)->GetArrayLength(env, channel_ids_conv_8) == 32);
31554                 (*env)->GetByteArrayRegion(env, channel_ids_conv_8, 0, 32, channel_ids_conv_8_ref.data);
31555                 channel_ids_constr.data[i] = channel_ids_conv_8_ref;
31556         }
31557         LDKChannelConfig config_conv;
31558         config_conv.inner = untag_ptr(config);
31559         config_conv.is_owned = ptr_is_owned(config);
31560         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
31561         config_conv.is_owned = false;
31562         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31563         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
31564         return tag_ptr(ret_conv, true);
31565 }
31566
31567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
31568         LDKChannelManager this_arg_conv;
31569         this_arg_conv.inner = untag_ptr(this_arg);
31570         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31572         this_arg_conv.is_owned = false;
31573         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
31574 }
31575
31576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
31577         LDKChannelManager this_arg_conv;
31578         this_arg_conv.inner = untag_ptr(this_arg);
31579         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31581         this_arg_conv.is_owned = false;
31582         ChannelManager_timer_tick_occurred(&this_arg_conv);
31583 }
31584
31585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
31586         LDKChannelManager this_arg_conv;
31587         this_arg_conv.inner = untag_ptr(this_arg);
31588         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31590         this_arg_conv.is_owned = false;
31591         unsigned char payment_hash_arr[32];
31592         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31593         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
31594         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
31595         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
31596 }
31597
31598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
31599         LDKChannelManager this_arg_conv;
31600         this_arg_conv.inner = untag_ptr(this_arg);
31601         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31603         this_arg_conv.is_owned = false;
31604         LDKThirtyTwoBytes payment_preimage_ref;
31605         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
31606         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
31607         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
31608 }
31609
31610 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
31611         LDKChannelManager this_arg_conv;
31612         this_arg_conv.inner = untag_ptr(this_arg);
31613         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31615         this_arg_conv.is_owned = false;
31616         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31617         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
31618         return ret_arr;
31619 }
31620
31621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1accept_1inbound_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t user_channel_id) {
31622         LDKChannelManager this_arg_conv;
31623         this_arg_conv.inner = untag_ptr(this_arg);
31624         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31626         this_arg_conv.is_owned = false;
31627         unsigned char temporary_channel_id_arr[32];
31628         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
31629         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
31630         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
31631         LDKPublicKey counterparty_node_id_ref;
31632         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31633         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31634         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31635         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
31636         return tag_ptr(ret_conv, true);
31637 }
31638
31639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1accept_1inbound_1channel_1from_1trusted_1peer_10conf(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray temporary_channel_id, int8_tArray counterparty_node_id, int64_t user_channel_id) {
31640         LDKChannelManager this_arg_conv;
31641         this_arg_conv.inner = untag_ptr(this_arg);
31642         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31644         this_arg_conv.is_owned = false;
31645         unsigned char temporary_channel_id_arr[32];
31646         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
31647         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
31648         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
31649         LDKPublicKey counterparty_node_id_ref;
31650         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
31651         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
31652         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
31653         *ret_conv = ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id);
31654         return tag_ptr(ret_conv, true);
31655 }
31656
31657 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) {
31658         LDKChannelManager this_arg_conv;
31659         this_arg_conv.inner = untag_ptr(this_arg);
31660         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31662         this_arg_conv.is_owned = false;
31663         void* min_value_msat_ptr = untag_ptr(min_value_msat);
31664         CHECK_ACCESS(min_value_msat_ptr);
31665         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31666         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
31667         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
31668         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
31669         return tag_ptr(ret_conv, true);
31670 }
31671
31672 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) {
31673         LDKChannelManager this_arg_conv;
31674         this_arg_conv.inner = untag_ptr(this_arg);
31675         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31677         this_arg_conv.is_owned = false;
31678         void* min_value_msat_ptr = untag_ptr(min_value_msat);
31679         CHECK_ACCESS(min_value_msat_ptr);
31680         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31681         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
31682         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
31683         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
31684         return tag_ptr(ret_conv, true);
31685 }
31686
31687 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) {
31688         LDKChannelManager this_arg_conv;
31689         this_arg_conv.inner = untag_ptr(this_arg);
31690         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31692         this_arg_conv.is_owned = false;
31693         LDKThirtyTwoBytes payment_hash_ref;
31694         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31695         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31696         void* min_value_msat_ptr = untag_ptr(min_value_msat);
31697         CHECK_ACCESS(min_value_msat_ptr);
31698         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31699         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
31700         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
31701         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
31702         return tag_ptr(ret_conv, true);
31703 }
31704
31705 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) {
31706         LDKChannelManager this_arg_conv;
31707         this_arg_conv.inner = untag_ptr(this_arg);
31708         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31710         this_arg_conv.is_owned = false;
31711         LDKThirtyTwoBytes payment_hash_ref;
31712         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31713         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31714         void* min_value_msat_ptr = untag_ptr(min_value_msat);
31715         CHECK_ACCESS(min_value_msat_ptr);
31716         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
31717         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
31718         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
31719         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
31720         return tag_ptr(ret_conv, true);
31721 }
31722
31723 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) {
31724         LDKChannelManager this_arg_conv;
31725         this_arg_conv.inner = untag_ptr(this_arg);
31726         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31728         this_arg_conv.is_owned = false;
31729         LDKThirtyTwoBytes payment_hash_ref;
31730         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
31731         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
31732         LDKThirtyTwoBytes payment_secret_ref;
31733         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
31734         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
31735         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
31736         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
31737         return tag_ptr(ret_conv, true);
31738 }
31739
31740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
31741         LDKChannelManager this_arg_conv;
31742         this_arg_conv.inner = untag_ptr(this_arg);
31743         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31745         this_arg_conv.is_owned = false;
31746         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
31747         return ret_conv;
31748 }
31749
31750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
31751         LDKChannelManager this_arg_conv;
31752         this_arg_conv.inner = untag_ptr(this_arg);
31753         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31755         this_arg_conv.is_owned = false;
31756         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
31757         int64_t ret_ref = 0;
31758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31759         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31760         return ret_ref;
31761 }
31762
31763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
31764         LDKChannelManager this_arg_conv;
31765         this_arg_conv.inner = untag_ptr(this_arg);
31766         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31768         this_arg_conv.is_owned = false;
31769         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
31770         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
31771         return tag_ptr(ret_ret, true);
31772 }
31773
31774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
31775         LDKChannelManager this_arg_conv;
31776         this_arg_conv.inner = untag_ptr(this_arg);
31777         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31779         this_arg_conv.is_owned = false;
31780         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
31781         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
31782         return tag_ptr(ret_ret, true);
31783 }
31784
31785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
31786         LDKChannelManager this_arg_conv;
31787         this_arg_conv.inner = untag_ptr(this_arg);
31788         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31790         this_arg_conv.is_owned = false;
31791         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
31792         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
31793         return tag_ptr(ret_ret, true);
31794 }
31795
31796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
31797         LDKChannelManager this_arg_conv;
31798         this_arg_conv.inner = untag_ptr(this_arg);
31799         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31801         this_arg_conv.is_owned = false;
31802         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
31803         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
31804         return tag_ptr(ret_ret, true);
31805 }
31806
31807 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) {
31808         LDKChannelManager this_arg_conv;
31809         this_arg_conv.inner = untag_ptr(this_arg);
31810         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31812         this_arg_conv.is_owned = false;
31813         jboolean ret_conv = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
31814         return ret_conv;
31815 }
31816
31817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
31818         LDKChannelManager this_arg_conv;
31819         this_arg_conv.inner = untag_ptr(this_arg);
31820         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31822         this_arg_conv.is_owned = false;
31823         ChannelManager_await_persistable_update(&this_arg_conv);
31824 }
31825
31826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1persistable_1update_1future(JNIEnv *env, jclass clz, int64_t this_arg) {
31827         LDKChannelManager this_arg_conv;
31828         this_arg_conv.inner = untag_ptr(this_arg);
31829         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31831         this_arg_conv.is_owned = false;
31832         LDKFuture ret_var = ChannelManager_get_persistable_update_future(&this_arg_conv);
31833         int64_t ret_ref = 0;
31834         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31835         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31836         return ret_ref;
31837 }
31838
31839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
31840         LDKChannelManager this_arg_conv;
31841         this_arg_conv.inner = untag_ptr(this_arg);
31842         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31844         this_arg_conv.is_owned = false;
31845         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
31846         int64_t ret_ref = 0;
31847         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31848         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31849         return ret_ref;
31850 }
31851
31852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
31853         LDKChannelManager this_arg_conv;
31854         this_arg_conv.inner = untag_ptr(this_arg);
31855         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31857         this_arg_conv.is_owned = false;
31858         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
31859         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
31860         return tag_ptr(ret_ret, true);
31861 }
31862
31863 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
31864         LDKCounterpartyForwardingInfo obj_conv;
31865         obj_conv.inner = untag_ptr(obj);
31866         obj_conv.is_owned = ptr_is_owned(obj);
31867         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31868         obj_conv.is_owned = false;
31869         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
31870         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31871         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31872         CVec_u8Z_free(ret_var);
31873         return ret_arr;
31874 }
31875
31876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31877         LDKu8slice ser_ref;
31878         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31879         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31880         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
31881         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
31882         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31883         return tag_ptr(ret_conv, true);
31884 }
31885
31886 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
31887         LDKChannelCounterparty obj_conv;
31888         obj_conv.inner = untag_ptr(obj);
31889         obj_conv.is_owned = ptr_is_owned(obj);
31890         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31891         obj_conv.is_owned = false;
31892         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
31893         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31894         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31895         CVec_u8Z_free(ret_var);
31896         return ret_arr;
31897 }
31898
31899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31900         LDKu8slice ser_ref;
31901         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31902         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31903         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
31904         *ret_conv = ChannelCounterparty_read(ser_ref);
31905         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31906         return tag_ptr(ret_conv, true);
31907 }
31908
31909 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
31910         LDKChannelDetails obj_conv;
31911         obj_conv.inner = untag_ptr(obj);
31912         obj_conv.is_owned = ptr_is_owned(obj);
31913         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31914         obj_conv.is_owned = false;
31915         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
31916         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31917         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31918         CVec_u8Z_free(ret_var);
31919         return ret_arr;
31920 }
31921
31922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31923         LDKu8slice ser_ref;
31924         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31925         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31926         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
31927         *ret_conv = ChannelDetails_read(ser_ref);
31928         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31929         return tag_ptr(ret_conv, true);
31930 }
31931
31932 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
31933         LDKPhantomRouteHints obj_conv;
31934         obj_conv.inner = untag_ptr(obj);
31935         obj_conv.is_owned = ptr_is_owned(obj);
31936         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31937         obj_conv.is_owned = false;
31938         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
31939         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31940         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31941         CVec_u8Z_free(ret_var);
31942         return ret_arr;
31943 }
31944
31945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31946         LDKu8slice ser_ref;
31947         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31948         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31949         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
31950         *ret_conv = PhantomRouteHints_read(ser_ref);
31951         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31952         return tag_ptr(ret_conv, true);
31953 }
31954
31955 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
31956         LDKChannelManager obj_conv;
31957         obj_conv.inner = untag_ptr(obj);
31958         obj_conv.is_owned = ptr_is_owned(obj);
31959         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31960         obj_conv.is_owned = false;
31961         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
31962         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31963         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31964         CVec_u8Z_free(ret_var);
31965         return ret_arr;
31966 }
31967
31968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31969         LDKChannelManagerReadArgs this_obj_conv;
31970         this_obj_conv.inner = untag_ptr(this_obj);
31971         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31973         ChannelManagerReadArgs_free(this_obj_conv);
31974 }
31975
31976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
31977         LDKChannelManagerReadArgs this_ptr_conv;
31978         this_ptr_conv.inner = untag_ptr(this_ptr);
31979         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31981         this_ptr_conv.is_owned = false;
31982         // WARNING: This object doesn't live past this scope, needs clone!
31983         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv), false);
31984         return ret_ret;
31985 }
31986
31987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31988         LDKChannelManagerReadArgs this_ptr_conv;
31989         this_ptr_conv.inner = untag_ptr(this_ptr);
31990         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31992         this_ptr_conv.is_owned = false;
31993         void* val_ptr = untag_ptr(val);
31994         CHECK_ACCESS(val_ptr);
31995         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
31996         if (val_conv.free == LDKKeysInterface_JCalls_free) {
31997                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31998                 LDKKeysInterface_JCalls_cloned(&val_conv);
31999         }
32000         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
32001 }
32002
32003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
32004         LDKChannelManagerReadArgs this_ptr_conv;
32005         this_ptr_conv.inner = untag_ptr(this_ptr);
32006         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32008         this_ptr_conv.is_owned = false;
32009         // WARNING: This object doesn't live past this scope, needs clone!
32010         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv), false);
32011         return ret_ret;
32012 }
32013
32014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32015         LDKChannelManagerReadArgs this_ptr_conv;
32016         this_ptr_conv.inner = untag_ptr(this_ptr);
32017         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32019         this_ptr_conv.is_owned = false;
32020         void* val_ptr = untag_ptr(val);
32021         CHECK_ACCESS(val_ptr);
32022         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
32023         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
32024                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32025                 LDKFeeEstimator_JCalls_cloned(&val_conv);
32026         }
32027         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
32028 }
32029
32030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
32031         LDKChannelManagerReadArgs this_ptr_conv;
32032         this_ptr_conv.inner = untag_ptr(this_ptr);
32033         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32035         this_ptr_conv.is_owned = false;
32036         // WARNING: This object doesn't live past this scope, needs clone!
32037         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv), false);
32038         return ret_ret;
32039 }
32040
32041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32042         LDKChannelManagerReadArgs this_ptr_conv;
32043         this_ptr_conv.inner = untag_ptr(this_ptr);
32044         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32046         this_ptr_conv.is_owned = false;
32047         void* val_ptr = untag_ptr(val);
32048         CHECK_ACCESS(val_ptr);
32049         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
32050         if (val_conv.free == LDKWatch_JCalls_free) {
32051                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32052                 LDKWatch_JCalls_cloned(&val_conv);
32053         }
32054         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
32055 }
32056
32057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
32058         LDKChannelManagerReadArgs this_ptr_conv;
32059         this_ptr_conv.inner = untag_ptr(this_ptr);
32060         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32062         this_ptr_conv.is_owned = false;
32063         // WARNING: This object doesn't live past this scope, needs clone!
32064         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv), false);
32065         return ret_ret;
32066 }
32067
32068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32069         LDKChannelManagerReadArgs this_ptr_conv;
32070         this_ptr_conv.inner = untag_ptr(this_ptr);
32071         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32073         this_ptr_conv.is_owned = false;
32074         void* val_ptr = untag_ptr(val);
32075         CHECK_ACCESS(val_ptr);
32076         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
32077         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
32078                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32079                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
32080         }
32081         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
32082 }
32083
32084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
32085         LDKChannelManagerReadArgs this_ptr_conv;
32086         this_ptr_conv.inner = untag_ptr(this_ptr);
32087         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32089         this_ptr_conv.is_owned = false;
32090         // WARNING: This object doesn't live past this scope, needs clone!
32091         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_logger(&this_ptr_conv), false);
32092         return ret_ret;
32093 }
32094
32095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32096         LDKChannelManagerReadArgs this_ptr_conv;
32097         this_ptr_conv.inner = untag_ptr(this_ptr);
32098         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32100         this_ptr_conv.is_owned = false;
32101         void* val_ptr = untag_ptr(val);
32102         CHECK_ACCESS(val_ptr);
32103         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
32104         if (val_conv.free == LDKLogger_JCalls_free) {
32105                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32106                 LDKLogger_JCalls_cloned(&val_conv);
32107         }
32108         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
32109 }
32110
32111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
32112         LDKChannelManagerReadArgs this_ptr_conv;
32113         this_ptr_conv.inner = untag_ptr(this_ptr);
32114         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32116         this_ptr_conv.is_owned = false;
32117         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
32118         int64_t ret_ref = 0;
32119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32120         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32121         return ret_ref;
32122 }
32123
32124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32125         LDKChannelManagerReadArgs this_ptr_conv;
32126         this_ptr_conv.inner = untag_ptr(this_ptr);
32127         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32129         this_ptr_conv.is_owned = false;
32130         LDKUserConfig val_conv;
32131         val_conv.inner = untag_ptr(val);
32132         val_conv.is_owned = ptr_is_owned(val);
32133         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32134         val_conv = UserConfig_clone(&val_conv);
32135         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
32136 }
32137
32138 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) {
32139         void* keys_manager_ptr = untag_ptr(keys_manager);
32140         CHECK_ACCESS(keys_manager_ptr);
32141         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
32142         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
32143                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32144                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
32145         }
32146         void* fee_estimator_ptr = untag_ptr(fee_estimator);
32147         CHECK_ACCESS(fee_estimator_ptr);
32148         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
32149         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
32150                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32151                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
32152         }
32153         void* chain_monitor_ptr = untag_ptr(chain_monitor);
32154         CHECK_ACCESS(chain_monitor_ptr);
32155         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
32156         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
32157                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32158                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
32159         }
32160         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
32161         CHECK_ACCESS(tx_broadcaster_ptr);
32162         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
32163         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
32164                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32165                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
32166         }
32167         void* logger_ptr = untag_ptr(logger);
32168         CHECK_ACCESS(logger_ptr);
32169         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
32170         if (logger_conv.free == LDKLogger_JCalls_free) {
32171                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32172                 LDKLogger_JCalls_cloned(&logger_conv);
32173         }
32174         LDKUserConfig default_config_conv;
32175         default_config_conv.inner = untag_ptr(default_config);
32176         default_config_conv.is_owned = ptr_is_owned(default_config);
32177         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
32178         default_config_conv = UserConfig_clone(&default_config_conv);
32179         LDKCVec_ChannelMonitorZ channel_monitors_constr;
32180         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
32181         if (channel_monitors_constr.datalen > 0)
32182                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
32183         else
32184                 channel_monitors_constr.data = NULL;
32185         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
32186         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
32187                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
32188                 LDKChannelMonitor channel_monitors_conv_16_conv;
32189                 channel_monitors_conv_16_conv.inner = untag_ptr(channel_monitors_conv_16);
32190                 channel_monitors_conv_16_conv.is_owned = ptr_is_owned(channel_monitors_conv_16);
32191                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
32192                 channel_monitors_conv_16_conv.is_owned = false;
32193                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
32194         }
32195         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
32196         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);
32197         int64_t ret_ref = 0;
32198         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32199         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32200         return ret_ref;
32201 }
32202
32203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
32204         LDKu8slice ser_ref;
32205         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32206         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32207         LDKChannelManagerReadArgs arg_conv;
32208         arg_conv.inner = untag_ptr(arg);
32209         arg_conv.is_owned = ptr_is_owned(arg);
32210         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32211         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
32212         
32213         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
32214         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
32215         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32216         return tag_ptr(ret_conv, true);
32217 }
32218
32219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32220         LDKExpandedKey this_obj_conv;
32221         this_obj_conv.inner = untag_ptr(this_obj);
32222         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32224         ExpandedKey_free(this_obj_conv);
32225 }
32226
32227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1new(JNIEnv *env, jclass clz, int8_tArray key_material) {
32228         unsigned char key_material_arr[32];
32229         CHECK((*env)->GetArrayLength(env, key_material) == 32);
32230         (*env)->GetByteArrayRegion(env, key_material, 0, 32, key_material_arr);
32231         unsigned char (*key_material_ref)[32] = &key_material_arr;
32232         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
32233         int64_t ret_ref = 0;
32234         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32235         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32236         return ret_ref;
32237 }
32238
32239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create(JNIEnv *env, jclass clz, int64_t keys, int64_t min_value_msat, int32_t invoice_expiry_delta_secs, int64_t keys_manager, int64_t current_time) {
32240         LDKExpandedKey keys_conv;
32241         keys_conv.inner = untag_ptr(keys);
32242         keys_conv.is_owned = ptr_is_owned(keys);
32243         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
32244         keys_conv.is_owned = false;
32245         void* min_value_msat_ptr = untag_ptr(min_value_msat);
32246         CHECK_ACCESS(min_value_msat_ptr);
32247         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
32248         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
32249         void* keys_manager_ptr = untag_ptr(keys_manager);
32250         if (ptr_is_owned(keys_manager)) { CHECK_ACCESS(keys_manager_ptr); }
32251         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
32252         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
32253         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, keys_manager_conv, current_time);
32254         return tag_ptr(ret_conv, true);
32255 }
32256
32257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1from_1hash(JNIEnv *env, jclass clz, int64_t keys, int64_t min_value_msat, int8_tArray payment_hash, int32_t invoice_expiry_delta_secs, int64_t current_time) {
32258         LDKExpandedKey keys_conv;
32259         keys_conv.inner = untag_ptr(keys);
32260         keys_conv.is_owned = ptr_is_owned(keys);
32261         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
32262         keys_conv.is_owned = false;
32263         void* min_value_msat_ptr = untag_ptr(min_value_msat);
32264         CHECK_ACCESS(min_value_msat_ptr);
32265         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
32266         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
32267         LDKThirtyTwoBytes payment_hash_ref;
32268         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32269         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32270         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
32271         *ret_conv = create_from_hash(&keys_conv, min_value_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, current_time);
32272         return tag_ptr(ret_conv, true);
32273 }
32274
32275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32276         LDKDecodeError this_obj_conv;
32277         this_obj_conv.inner = untag_ptr(this_obj);
32278         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32280         DecodeError_free(this_obj_conv);
32281 }
32282
32283 static inline uint64_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
32284         LDKDecodeError ret_var = DecodeError_clone(arg);
32285         int64_t ret_ref = 0;
32286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32287         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32288         return ret_ref;
32289 }
32290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32291         LDKDecodeError arg_conv;
32292         arg_conv.inner = untag_ptr(arg);
32293         arg_conv.is_owned = ptr_is_owned(arg);
32294         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32295         arg_conv.is_owned = false;
32296         int64_t ret_conv = DecodeError_clone_ptr(&arg_conv);
32297         return ret_conv;
32298 }
32299
32300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32301         LDKDecodeError orig_conv;
32302         orig_conv.inner = untag_ptr(orig);
32303         orig_conv.is_owned = ptr_is_owned(orig);
32304         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32305         orig_conv.is_owned = false;
32306         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
32307         int64_t ret_ref = 0;
32308         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32309         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32310         return ret_ref;
32311 }
32312
32313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32314         LDKInit this_obj_conv;
32315         this_obj_conv.inner = untag_ptr(this_obj);
32316         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32318         Init_free(this_obj_conv);
32319 }
32320
32321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
32322         LDKInit this_ptr_conv;
32323         this_ptr_conv.inner = untag_ptr(this_ptr);
32324         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32326         this_ptr_conv.is_owned = false;
32327         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
32328         int64_t ret_ref = 0;
32329         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32330         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32331         return ret_ref;
32332 }
32333
32334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32335         LDKInit this_ptr_conv;
32336         this_ptr_conv.inner = untag_ptr(this_ptr);
32337         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32339         this_ptr_conv.is_owned = false;
32340         LDKInitFeatures val_conv;
32341         val_conv.inner = untag_ptr(val);
32342         val_conv.is_owned = ptr_is_owned(val);
32343         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32344         val_conv = InitFeatures_clone(&val_conv);
32345         Init_set_features(&this_ptr_conv, val_conv);
32346 }
32347
32348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr) {
32349         LDKInit this_ptr_conv;
32350         this_ptr_conv.inner = untag_ptr(this_ptr);
32351         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32353         this_ptr_conv.is_owned = false;
32354         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
32355         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
32356         int64_t ret_ref = tag_ptr(ret_copy, true);
32357         return ret_ref;
32358 }
32359
32360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32361         LDKInit this_ptr_conv;
32362         this_ptr_conv.inner = untag_ptr(this_ptr);
32363         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32365         this_ptr_conv.is_owned = false;
32366         void* val_ptr = untag_ptr(val);
32367         CHECK_ACCESS(val_ptr);
32368         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
32369         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)untag_ptr(val));
32370         Init_set_remote_network_address(&this_ptr_conv, val_conv);
32371 }
32372
32373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg, int64_t remote_network_address_arg) {
32374         LDKInitFeatures features_arg_conv;
32375         features_arg_conv.inner = untag_ptr(features_arg);
32376         features_arg_conv.is_owned = ptr_is_owned(features_arg);
32377         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
32378         features_arg_conv = InitFeatures_clone(&features_arg_conv);
32379         void* remote_network_address_arg_ptr = untag_ptr(remote_network_address_arg);
32380         CHECK_ACCESS(remote_network_address_arg_ptr);
32381         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
32382         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
32383         int64_t ret_ref = 0;
32384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32385         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32386         return ret_ref;
32387 }
32388
32389 static inline uint64_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
32390         LDKInit ret_var = Init_clone(arg);
32391         int64_t ret_ref = 0;
32392         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32393         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32394         return ret_ref;
32395 }
32396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32397         LDKInit arg_conv;
32398         arg_conv.inner = untag_ptr(arg);
32399         arg_conv.is_owned = ptr_is_owned(arg);
32400         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32401         arg_conv.is_owned = false;
32402         int64_t ret_conv = Init_clone_ptr(&arg_conv);
32403         return ret_conv;
32404 }
32405
32406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32407         LDKInit orig_conv;
32408         orig_conv.inner = untag_ptr(orig);
32409         orig_conv.is_owned = ptr_is_owned(orig);
32410         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32411         orig_conv.is_owned = false;
32412         LDKInit ret_var = Init_clone(&orig_conv);
32413         int64_t ret_ref = 0;
32414         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32415         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32416         return ret_ref;
32417 }
32418
32419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32420         LDKErrorMessage this_obj_conv;
32421         this_obj_conv.inner = untag_ptr(this_obj);
32422         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32424         ErrorMessage_free(this_obj_conv);
32425 }
32426
32427 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32428         LDKErrorMessage this_ptr_conv;
32429         this_ptr_conv.inner = untag_ptr(this_ptr);
32430         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32432         this_ptr_conv.is_owned = false;
32433         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32434         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
32435         return ret_arr;
32436 }
32437
32438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32439         LDKErrorMessage this_ptr_conv;
32440         this_ptr_conv.inner = untag_ptr(this_ptr);
32441         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32443         this_ptr_conv.is_owned = false;
32444         LDKThirtyTwoBytes val_ref;
32445         CHECK((*env)->GetArrayLength(env, val) == 32);
32446         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32447         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
32448 }
32449
32450 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
32451         LDKErrorMessage this_ptr_conv;
32452         this_ptr_conv.inner = untag_ptr(this_ptr);
32453         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32455         this_ptr_conv.is_owned = false;
32456         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
32457         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
32458         Str_free(ret_str);
32459         return ret_conv;
32460 }
32461
32462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
32463         LDKErrorMessage this_ptr_conv;
32464         this_ptr_conv.inner = untag_ptr(this_ptr);
32465         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32467         this_ptr_conv.is_owned = false;
32468         LDKStr val_conv = java_to_owned_str(env, val);
32469         ErrorMessage_set_data(&this_ptr_conv, val_conv);
32470 }
32471
32472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
32473         LDKThirtyTwoBytes channel_id_arg_ref;
32474         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32475         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32476         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
32477         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
32478         int64_t ret_ref = 0;
32479         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32480         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32481         return ret_ref;
32482 }
32483
32484 static inline uint64_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
32485         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
32486         int64_t ret_ref = 0;
32487         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32488         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32489         return ret_ref;
32490 }
32491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32492         LDKErrorMessage arg_conv;
32493         arg_conv.inner = untag_ptr(arg);
32494         arg_conv.is_owned = ptr_is_owned(arg);
32495         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32496         arg_conv.is_owned = false;
32497         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
32498         return ret_conv;
32499 }
32500
32501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32502         LDKErrorMessage orig_conv;
32503         orig_conv.inner = untag_ptr(orig);
32504         orig_conv.is_owned = ptr_is_owned(orig);
32505         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32506         orig_conv.is_owned = false;
32507         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
32508         int64_t ret_ref = 0;
32509         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32510         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32511         return ret_ref;
32512 }
32513
32514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32515         LDKWarningMessage this_obj_conv;
32516         this_obj_conv.inner = untag_ptr(this_obj);
32517         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32519         WarningMessage_free(this_obj_conv);
32520 }
32521
32522 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32523         LDKWarningMessage this_ptr_conv;
32524         this_ptr_conv.inner = untag_ptr(this_ptr);
32525         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32527         this_ptr_conv.is_owned = false;
32528         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32529         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
32530         return ret_arr;
32531 }
32532
32533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32534         LDKWarningMessage this_ptr_conv;
32535         this_ptr_conv.inner = untag_ptr(this_ptr);
32536         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32538         this_ptr_conv.is_owned = false;
32539         LDKThirtyTwoBytes val_ref;
32540         CHECK((*env)->GetArrayLength(env, val) == 32);
32541         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32542         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
32543 }
32544
32545 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
32546         LDKWarningMessage this_ptr_conv;
32547         this_ptr_conv.inner = untag_ptr(this_ptr);
32548         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32550         this_ptr_conv.is_owned = false;
32551         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
32552         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
32553         Str_free(ret_str);
32554         return ret_conv;
32555 }
32556
32557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
32558         LDKWarningMessage this_ptr_conv;
32559         this_ptr_conv.inner = untag_ptr(this_ptr);
32560         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32561         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32562         this_ptr_conv.is_owned = false;
32563         LDKStr val_conv = java_to_owned_str(env, val);
32564         WarningMessage_set_data(&this_ptr_conv, val_conv);
32565 }
32566
32567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
32568         LDKThirtyTwoBytes channel_id_arg_ref;
32569         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32570         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32571         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
32572         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
32573         int64_t ret_ref = 0;
32574         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32575         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32576         return ret_ref;
32577 }
32578
32579 static inline uint64_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
32580         LDKWarningMessage ret_var = WarningMessage_clone(arg);
32581         int64_t ret_ref = 0;
32582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32583         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32584         return ret_ref;
32585 }
32586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32587         LDKWarningMessage arg_conv;
32588         arg_conv.inner = untag_ptr(arg);
32589         arg_conv.is_owned = ptr_is_owned(arg);
32590         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32591         arg_conv.is_owned = false;
32592         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
32593         return ret_conv;
32594 }
32595
32596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32597         LDKWarningMessage orig_conv;
32598         orig_conv.inner = untag_ptr(orig);
32599         orig_conv.is_owned = ptr_is_owned(orig);
32600         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32601         orig_conv.is_owned = false;
32602         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
32603         int64_t ret_ref = 0;
32604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32605         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32606         return ret_ref;
32607 }
32608
32609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32610         LDKPing this_obj_conv;
32611         this_obj_conv.inner = untag_ptr(this_obj);
32612         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32614         Ping_free(this_obj_conv);
32615 }
32616
32617 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
32618         LDKPing this_ptr_conv;
32619         this_ptr_conv.inner = untag_ptr(this_ptr);
32620         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32622         this_ptr_conv.is_owned = false;
32623         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
32624         return ret_conv;
32625 }
32626
32627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32628         LDKPing this_ptr_conv;
32629         this_ptr_conv.inner = untag_ptr(this_ptr);
32630         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32632         this_ptr_conv.is_owned = false;
32633         Ping_set_ponglen(&this_ptr_conv, val);
32634 }
32635
32636 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
32637         LDKPing this_ptr_conv;
32638         this_ptr_conv.inner = untag_ptr(this_ptr);
32639         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32641         this_ptr_conv.is_owned = false;
32642         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
32643         return ret_conv;
32644 }
32645
32646 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32647         LDKPing this_ptr_conv;
32648         this_ptr_conv.inner = untag_ptr(this_ptr);
32649         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32651         this_ptr_conv.is_owned = false;
32652         Ping_set_byteslen(&this_ptr_conv, val);
32653 }
32654
32655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
32656         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
32657         int64_t ret_ref = 0;
32658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32659         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32660         return ret_ref;
32661 }
32662
32663 static inline uint64_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
32664         LDKPing ret_var = Ping_clone(arg);
32665         int64_t ret_ref = 0;
32666         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32667         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32668         return ret_ref;
32669 }
32670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32671         LDKPing arg_conv;
32672         arg_conv.inner = untag_ptr(arg);
32673         arg_conv.is_owned = ptr_is_owned(arg);
32674         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32675         arg_conv.is_owned = false;
32676         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
32677         return ret_conv;
32678 }
32679
32680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32681         LDKPing orig_conv;
32682         orig_conv.inner = untag_ptr(orig);
32683         orig_conv.is_owned = ptr_is_owned(orig);
32684         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32685         orig_conv.is_owned = false;
32686         LDKPing ret_var = Ping_clone(&orig_conv);
32687         int64_t ret_ref = 0;
32688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32689         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32690         return ret_ref;
32691 }
32692
32693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32694         LDKPong this_obj_conv;
32695         this_obj_conv.inner = untag_ptr(this_obj);
32696         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32698         Pong_free(this_obj_conv);
32699 }
32700
32701 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
32702         LDKPong this_ptr_conv;
32703         this_ptr_conv.inner = untag_ptr(this_ptr);
32704         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32706         this_ptr_conv.is_owned = false;
32707         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
32708         return ret_conv;
32709 }
32710
32711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32712         LDKPong this_ptr_conv;
32713         this_ptr_conv.inner = untag_ptr(this_ptr);
32714         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32716         this_ptr_conv.is_owned = false;
32717         Pong_set_byteslen(&this_ptr_conv, val);
32718 }
32719
32720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
32721         LDKPong ret_var = Pong_new(byteslen_arg);
32722         int64_t ret_ref = 0;
32723         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32724         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32725         return ret_ref;
32726 }
32727
32728 static inline uint64_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
32729         LDKPong ret_var = Pong_clone(arg);
32730         int64_t ret_ref = 0;
32731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32732         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32733         return ret_ref;
32734 }
32735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32736         LDKPong arg_conv;
32737         arg_conv.inner = untag_ptr(arg);
32738         arg_conv.is_owned = ptr_is_owned(arg);
32739         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32740         arg_conv.is_owned = false;
32741         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
32742         return ret_conv;
32743 }
32744
32745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32746         LDKPong orig_conv;
32747         orig_conv.inner = untag_ptr(orig);
32748         orig_conv.is_owned = ptr_is_owned(orig);
32749         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32750         orig_conv.is_owned = false;
32751         LDKPong ret_var = Pong_clone(&orig_conv);
32752         int64_t ret_ref = 0;
32753         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32754         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32755         return ret_ref;
32756 }
32757
32758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32759         LDKOpenChannel this_obj_conv;
32760         this_obj_conv.inner = untag_ptr(this_obj);
32761         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32763         OpenChannel_free(this_obj_conv);
32764 }
32765
32766 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
32767         LDKOpenChannel this_ptr_conv;
32768         this_ptr_conv.inner = untag_ptr(this_ptr);
32769         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32771         this_ptr_conv.is_owned = false;
32772         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32773         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
32774         return ret_arr;
32775 }
32776
32777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32778         LDKOpenChannel this_ptr_conv;
32779         this_ptr_conv.inner = untag_ptr(this_ptr);
32780         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32782         this_ptr_conv.is_owned = false;
32783         LDKThirtyTwoBytes val_ref;
32784         CHECK((*env)->GetArrayLength(env, val) == 32);
32785         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32786         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
32787 }
32788
32789 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
32790         LDKOpenChannel this_ptr_conv;
32791         this_ptr_conv.inner = untag_ptr(this_ptr);
32792         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32793         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32794         this_ptr_conv.is_owned = false;
32795         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32796         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
32797         return ret_arr;
32798 }
32799
32800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32801         LDKOpenChannel this_ptr_conv;
32802         this_ptr_conv.inner = untag_ptr(this_ptr);
32803         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32805         this_ptr_conv.is_owned = false;
32806         LDKThirtyTwoBytes val_ref;
32807         CHECK((*env)->GetArrayLength(env, val) == 32);
32808         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32809         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
32810 }
32811
32812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32813         LDKOpenChannel this_ptr_conv;
32814         this_ptr_conv.inner = untag_ptr(this_ptr);
32815         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32817         this_ptr_conv.is_owned = false;
32818         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
32819         return ret_conv;
32820 }
32821
32822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32823         LDKOpenChannel this_ptr_conv;
32824         this_ptr_conv.inner = untag_ptr(this_ptr);
32825         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32827         this_ptr_conv.is_owned = false;
32828         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
32829 }
32830
32831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32832         LDKOpenChannel this_ptr_conv;
32833         this_ptr_conv.inner = untag_ptr(this_ptr);
32834         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32836         this_ptr_conv.is_owned = false;
32837         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
32838         return ret_conv;
32839 }
32840
32841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32842         LDKOpenChannel this_ptr_conv;
32843         this_ptr_conv.inner = untag_ptr(this_ptr);
32844         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32846         this_ptr_conv.is_owned = false;
32847         OpenChannel_set_push_msat(&this_ptr_conv, val);
32848 }
32849
32850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32851         LDKOpenChannel this_ptr_conv;
32852         this_ptr_conv.inner = untag_ptr(this_ptr);
32853         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32855         this_ptr_conv.is_owned = false;
32856         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
32857         return ret_conv;
32858 }
32859
32860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32861         LDKOpenChannel this_ptr_conv;
32862         this_ptr_conv.inner = untag_ptr(this_ptr);
32863         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32865         this_ptr_conv.is_owned = false;
32866         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
32867 }
32868
32869 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) {
32870         LDKOpenChannel this_ptr_conv;
32871         this_ptr_conv.inner = untag_ptr(this_ptr);
32872         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32874         this_ptr_conv.is_owned = false;
32875         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
32876         return ret_conv;
32877 }
32878
32879 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) {
32880         LDKOpenChannel this_ptr_conv;
32881         this_ptr_conv.inner = untag_ptr(this_ptr);
32882         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32884         this_ptr_conv.is_owned = false;
32885         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
32886 }
32887
32888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
32889         LDKOpenChannel this_ptr_conv;
32890         this_ptr_conv.inner = untag_ptr(this_ptr);
32891         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32893         this_ptr_conv.is_owned = false;
32894         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
32895         return ret_conv;
32896 }
32897
32898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32899         LDKOpenChannel this_ptr_conv;
32900         this_ptr_conv.inner = untag_ptr(this_ptr);
32901         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32903         this_ptr_conv.is_owned = false;
32904         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
32905 }
32906
32907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32908         LDKOpenChannel this_ptr_conv;
32909         this_ptr_conv.inner = untag_ptr(this_ptr);
32910         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32912         this_ptr_conv.is_owned = false;
32913         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
32914         return ret_conv;
32915 }
32916
32917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32918         LDKOpenChannel this_ptr_conv;
32919         this_ptr_conv.inner = untag_ptr(this_ptr);
32920         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32922         this_ptr_conv.is_owned = false;
32923         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
32924 }
32925
32926 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
32927         LDKOpenChannel this_ptr_conv;
32928         this_ptr_conv.inner = untag_ptr(this_ptr);
32929         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32931         this_ptr_conv.is_owned = false;
32932         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
32933         return ret_conv;
32934 }
32935
32936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32937         LDKOpenChannel this_ptr_conv;
32938         this_ptr_conv.inner = untag_ptr(this_ptr);
32939         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32941         this_ptr_conv.is_owned = false;
32942         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
32943 }
32944
32945 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
32946         LDKOpenChannel this_ptr_conv;
32947         this_ptr_conv.inner = untag_ptr(this_ptr);
32948         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32950         this_ptr_conv.is_owned = false;
32951         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
32952         return ret_conv;
32953 }
32954
32955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32956         LDKOpenChannel this_ptr_conv;
32957         this_ptr_conv.inner = untag_ptr(this_ptr);
32958         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32960         this_ptr_conv.is_owned = false;
32961         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
32962 }
32963
32964 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
32965         LDKOpenChannel this_ptr_conv;
32966         this_ptr_conv.inner = untag_ptr(this_ptr);
32967         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32969         this_ptr_conv.is_owned = false;
32970         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
32971         return ret_conv;
32972 }
32973
32974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32975         LDKOpenChannel this_ptr_conv;
32976         this_ptr_conv.inner = untag_ptr(this_ptr);
32977         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32979         this_ptr_conv.is_owned = false;
32980         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
32981 }
32982
32983 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
32984         LDKOpenChannel this_ptr_conv;
32985         this_ptr_conv.inner = untag_ptr(this_ptr);
32986         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32988         this_ptr_conv.is_owned = false;
32989         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32990         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
32991         return ret_arr;
32992 }
32993
32994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32995         LDKOpenChannel this_ptr_conv;
32996         this_ptr_conv.inner = untag_ptr(this_ptr);
32997         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32999         this_ptr_conv.is_owned = false;
33000         LDKPublicKey val_ref;
33001         CHECK((*env)->GetArrayLength(env, val) == 33);
33002         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33003         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
33004 }
33005
33006 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
33007         LDKOpenChannel this_ptr_conv;
33008         this_ptr_conv.inner = untag_ptr(this_ptr);
33009         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33011         this_ptr_conv.is_owned = false;
33012         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33013         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
33014         return ret_arr;
33015 }
33016
33017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33018         LDKOpenChannel this_ptr_conv;
33019         this_ptr_conv.inner = untag_ptr(this_ptr);
33020         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33022         this_ptr_conv.is_owned = false;
33023         LDKPublicKey val_ref;
33024         CHECK((*env)->GetArrayLength(env, val) == 33);
33025         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33026         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
33027 }
33028
33029 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
33030         LDKOpenChannel this_ptr_conv;
33031         this_ptr_conv.inner = untag_ptr(this_ptr);
33032         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33034         this_ptr_conv.is_owned = false;
33035         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33036         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
33037         return ret_arr;
33038 }
33039
33040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33041         LDKOpenChannel this_ptr_conv;
33042         this_ptr_conv.inner = untag_ptr(this_ptr);
33043         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33045         this_ptr_conv.is_owned = false;
33046         LDKPublicKey val_ref;
33047         CHECK((*env)->GetArrayLength(env, val) == 33);
33048         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33049         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
33050 }
33051
33052 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
33053         LDKOpenChannel this_ptr_conv;
33054         this_ptr_conv.inner = untag_ptr(this_ptr);
33055         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33057         this_ptr_conv.is_owned = false;
33058         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33059         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
33060         return ret_arr;
33061 }
33062
33063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33064         LDKOpenChannel this_ptr_conv;
33065         this_ptr_conv.inner = untag_ptr(this_ptr);
33066         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33068         this_ptr_conv.is_owned = false;
33069         LDKPublicKey val_ref;
33070         CHECK((*env)->GetArrayLength(env, val) == 33);
33071         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33072         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
33073 }
33074
33075 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
33076         LDKOpenChannel this_ptr_conv;
33077         this_ptr_conv.inner = untag_ptr(this_ptr);
33078         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33080         this_ptr_conv.is_owned = false;
33081         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33082         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
33083         return ret_arr;
33084 }
33085
33086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33087         LDKOpenChannel this_ptr_conv;
33088         this_ptr_conv.inner = untag_ptr(this_ptr);
33089         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33091         this_ptr_conv.is_owned = false;
33092         LDKPublicKey val_ref;
33093         CHECK((*env)->GetArrayLength(env, val) == 33);
33094         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33095         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
33096 }
33097
33098 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
33099         LDKOpenChannel this_ptr_conv;
33100         this_ptr_conv.inner = untag_ptr(this_ptr);
33101         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33103         this_ptr_conv.is_owned = false;
33104         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33105         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
33106         return ret_arr;
33107 }
33108
33109 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) {
33110         LDKOpenChannel this_ptr_conv;
33111         this_ptr_conv.inner = untag_ptr(this_ptr);
33112         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33114         this_ptr_conv.is_owned = false;
33115         LDKPublicKey val_ref;
33116         CHECK((*env)->GetArrayLength(env, val) == 33);
33117         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33118         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
33119 }
33120
33121 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
33122         LDKOpenChannel this_ptr_conv;
33123         this_ptr_conv.inner = untag_ptr(this_ptr);
33124         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33126         this_ptr_conv.is_owned = false;
33127         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
33128         return ret_conv;
33129 }
33130
33131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
33132         LDKOpenChannel this_ptr_conv;
33133         this_ptr_conv.inner = untag_ptr(this_ptr);
33134         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33136         this_ptr_conv.is_owned = false;
33137         OpenChannel_set_channel_flags(&this_ptr_conv, val);
33138 }
33139
33140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
33141         LDKOpenChannel this_ptr_conv;
33142         this_ptr_conv.inner = untag_ptr(this_ptr);
33143         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33145         this_ptr_conv.is_owned = false;
33146         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
33147         int64_t ret_ref = 0;
33148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33149         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33150         return ret_ref;
33151 }
33152
33153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33154         LDKOpenChannel this_ptr_conv;
33155         this_ptr_conv.inner = untag_ptr(this_ptr);
33156         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33158         this_ptr_conv.is_owned = false;
33159         LDKChannelTypeFeatures val_conv;
33160         val_conv.inner = untag_ptr(val);
33161         val_conv.is_owned = ptr_is_owned(val);
33162         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33163         val_conv = ChannelTypeFeatures_clone(&val_conv);
33164         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
33165 }
33166
33167 static inline uint64_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
33168         LDKOpenChannel ret_var = OpenChannel_clone(arg);
33169         int64_t ret_ref = 0;
33170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33171         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33172         return ret_ref;
33173 }
33174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33175         LDKOpenChannel arg_conv;
33176         arg_conv.inner = untag_ptr(arg);
33177         arg_conv.is_owned = ptr_is_owned(arg);
33178         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33179         arg_conv.is_owned = false;
33180         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
33181         return ret_conv;
33182 }
33183
33184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33185         LDKOpenChannel orig_conv;
33186         orig_conv.inner = untag_ptr(orig);
33187         orig_conv.is_owned = ptr_is_owned(orig);
33188         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33189         orig_conv.is_owned = false;
33190         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
33191         int64_t ret_ref = 0;
33192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33193         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33194         return ret_ref;
33195 }
33196
33197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33198         LDKAcceptChannel this_obj_conv;
33199         this_obj_conv.inner = untag_ptr(this_obj);
33200         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33202         AcceptChannel_free(this_obj_conv);
33203 }
33204
33205 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33206         LDKAcceptChannel this_ptr_conv;
33207         this_ptr_conv.inner = untag_ptr(this_ptr);
33208         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33210         this_ptr_conv.is_owned = false;
33211         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33212         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
33213         return ret_arr;
33214 }
33215
33216 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33217         LDKAcceptChannel this_ptr_conv;
33218         this_ptr_conv.inner = untag_ptr(this_ptr);
33219         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33221         this_ptr_conv.is_owned = false;
33222         LDKThirtyTwoBytes val_ref;
33223         CHECK((*env)->GetArrayLength(env, val) == 32);
33224         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33225         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
33226 }
33227
33228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33229         LDKAcceptChannel this_ptr_conv;
33230         this_ptr_conv.inner = untag_ptr(this_ptr);
33231         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33233         this_ptr_conv.is_owned = false;
33234         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
33235         return ret_conv;
33236 }
33237
33238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33239         LDKAcceptChannel this_ptr_conv;
33240         this_ptr_conv.inner = untag_ptr(this_ptr);
33241         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33243         this_ptr_conv.is_owned = false;
33244         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
33245 }
33246
33247 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) {
33248         LDKAcceptChannel this_ptr_conv;
33249         this_ptr_conv.inner = untag_ptr(this_ptr);
33250         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33252         this_ptr_conv.is_owned = false;
33253         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
33254         return ret_conv;
33255 }
33256
33257 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) {
33258         LDKAcceptChannel this_ptr_conv;
33259         this_ptr_conv.inner = untag_ptr(this_ptr);
33260         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33262         this_ptr_conv.is_owned = false;
33263         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
33264 }
33265
33266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
33267         LDKAcceptChannel this_ptr_conv;
33268         this_ptr_conv.inner = untag_ptr(this_ptr);
33269         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33271         this_ptr_conv.is_owned = false;
33272         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
33273         return ret_conv;
33274 }
33275
33276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33277         LDKAcceptChannel this_ptr_conv;
33278         this_ptr_conv.inner = untag_ptr(this_ptr);
33279         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33281         this_ptr_conv.is_owned = false;
33282         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
33283 }
33284
33285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
33286         LDKAcceptChannel this_ptr_conv;
33287         this_ptr_conv.inner = untag_ptr(this_ptr);
33288         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33290         this_ptr_conv.is_owned = false;
33291         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
33292         return ret_conv;
33293 }
33294
33295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33296         LDKAcceptChannel this_ptr_conv;
33297         this_ptr_conv.inner = untag_ptr(this_ptr);
33298         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33300         this_ptr_conv.is_owned = false;
33301         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
33302 }
33303
33304 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
33305         LDKAcceptChannel this_ptr_conv;
33306         this_ptr_conv.inner = untag_ptr(this_ptr);
33307         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33309         this_ptr_conv.is_owned = false;
33310         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
33311         return ret_conv;
33312 }
33313
33314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
33315         LDKAcceptChannel this_ptr_conv;
33316         this_ptr_conv.inner = untag_ptr(this_ptr);
33317         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33319         this_ptr_conv.is_owned = false;
33320         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
33321 }
33322
33323 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
33324         LDKAcceptChannel this_ptr_conv;
33325         this_ptr_conv.inner = untag_ptr(this_ptr);
33326         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33328         this_ptr_conv.is_owned = false;
33329         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
33330         return ret_conv;
33331 }
33332
33333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33334         LDKAcceptChannel this_ptr_conv;
33335         this_ptr_conv.inner = untag_ptr(this_ptr);
33336         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33338         this_ptr_conv.is_owned = false;
33339         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
33340 }
33341
33342 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
33343         LDKAcceptChannel this_ptr_conv;
33344         this_ptr_conv.inner = untag_ptr(this_ptr);
33345         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33347         this_ptr_conv.is_owned = false;
33348         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
33349         return ret_conv;
33350 }
33351
33352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33353         LDKAcceptChannel this_ptr_conv;
33354         this_ptr_conv.inner = untag_ptr(this_ptr);
33355         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33357         this_ptr_conv.is_owned = false;
33358         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
33359 }
33360
33361 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
33362         LDKAcceptChannel this_ptr_conv;
33363         this_ptr_conv.inner = untag_ptr(this_ptr);
33364         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33366         this_ptr_conv.is_owned = false;
33367         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33368         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
33369         return ret_arr;
33370 }
33371
33372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33373         LDKAcceptChannel this_ptr_conv;
33374         this_ptr_conv.inner = untag_ptr(this_ptr);
33375         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33377         this_ptr_conv.is_owned = false;
33378         LDKPublicKey val_ref;
33379         CHECK((*env)->GetArrayLength(env, val) == 33);
33380         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33381         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
33382 }
33383
33384 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
33385         LDKAcceptChannel this_ptr_conv;
33386         this_ptr_conv.inner = untag_ptr(this_ptr);
33387         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33389         this_ptr_conv.is_owned = false;
33390         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33391         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
33392         return ret_arr;
33393 }
33394
33395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33396         LDKAcceptChannel this_ptr_conv;
33397         this_ptr_conv.inner = untag_ptr(this_ptr);
33398         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33399         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33400         this_ptr_conv.is_owned = false;
33401         LDKPublicKey val_ref;
33402         CHECK((*env)->GetArrayLength(env, val) == 33);
33403         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33404         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
33405 }
33406
33407 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
33408         LDKAcceptChannel this_ptr_conv;
33409         this_ptr_conv.inner = untag_ptr(this_ptr);
33410         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33412         this_ptr_conv.is_owned = false;
33413         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33414         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
33415         return ret_arr;
33416 }
33417
33418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33419         LDKAcceptChannel this_ptr_conv;
33420         this_ptr_conv.inner = untag_ptr(this_ptr);
33421         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33423         this_ptr_conv.is_owned = false;
33424         LDKPublicKey val_ref;
33425         CHECK((*env)->GetArrayLength(env, val) == 33);
33426         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33427         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
33428 }
33429
33430 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
33431         LDKAcceptChannel this_ptr_conv;
33432         this_ptr_conv.inner = untag_ptr(this_ptr);
33433         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33435         this_ptr_conv.is_owned = false;
33436         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33437         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
33438         return ret_arr;
33439 }
33440
33441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33442         LDKAcceptChannel this_ptr_conv;
33443         this_ptr_conv.inner = untag_ptr(this_ptr);
33444         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33446         this_ptr_conv.is_owned = false;
33447         LDKPublicKey val_ref;
33448         CHECK((*env)->GetArrayLength(env, val) == 33);
33449         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33450         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
33451 }
33452
33453 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
33454         LDKAcceptChannel this_ptr_conv;
33455         this_ptr_conv.inner = untag_ptr(this_ptr);
33456         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33458         this_ptr_conv.is_owned = false;
33459         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33460         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
33461         return ret_arr;
33462 }
33463
33464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33465         LDKAcceptChannel this_ptr_conv;
33466         this_ptr_conv.inner = untag_ptr(this_ptr);
33467         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33469         this_ptr_conv.is_owned = false;
33470         LDKPublicKey val_ref;
33471         CHECK((*env)->GetArrayLength(env, val) == 33);
33472         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33473         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
33474 }
33475
33476 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
33477         LDKAcceptChannel this_ptr_conv;
33478         this_ptr_conv.inner = untag_ptr(this_ptr);
33479         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33481         this_ptr_conv.is_owned = false;
33482         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33483         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
33484         return ret_arr;
33485 }
33486
33487 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) {
33488         LDKAcceptChannel this_ptr_conv;
33489         this_ptr_conv.inner = untag_ptr(this_ptr);
33490         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33492         this_ptr_conv.is_owned = false;
33493         LDKPublicKey val_ref;
33494         CHECK((*env)->GetArrayLength(env, val) == 33);
33495         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33496         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
33497 }
33498
33499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
33500         LDKAcceptChannel this_ptr_conv;
33501         this_ptr_conv.inner = untag_ptr(this_ptr);
33502         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33504         this_ptr_conv.is_owned = false;
33505         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
33506         int64_t ret_ref = 0;
33507         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33508         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33509         return ret_ref;
33510 }
33511
33512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33513         LDKAcceptChannel this_ptr_conv;
33514         this_ptr_conv.inner = untag_ptr(this_ptr);
33515         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33517         this_ptr_conv.is_owned = false;
33518         LDKChannelTypeFeatures val_conv;
33519         val_conv.inner = untag_ptr(val);
33520         val_conv.is_owned = ptr_is_owned(val);
33521         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33522         val_conv = ChannelTypeFeatures_clone(&val_conv);
33523         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
33524 }
33525
33526 static inline uint64_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
33527         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
33528         int64_t ret_ref = 0;
33529         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33530         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33531         return ret_ref;
33532 }
33533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33534         LDKAcceptChannel arg_conv;
33535         arg_conv.inner = untag_ptr(arg);
33536         arg_conv.is_owned = ptr_is_owned(arg);
33537         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33538         arg_conv.is_owned = false;
33539         int64_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
33540         return ret_conv;
33541 }
33542
33543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33544         LDKAcceptChannel orig_conv;
33545         orig_conv.inner = untag_ptr(orig);
33546         orig_conv.is_owned = ptr_is_owned(orig);
33547         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33548         orig_conv.is_owned = false;
33549         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
33550         int64_t ret_ref = 0;
33551         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33552         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33553         return ret_ref;
33554 }
33555
33556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33557         LDKFundingCreated this_obj_conv;
33558         this_obj_conv.inner = untag_ptr(this_obj);
33559         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33561         FundingCreated_free(this_obj_conv);
33562 }
33563
33564 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33565         LDKFundingCreated this_ptr_conv;
33566         this_ptr_conv.inner = untag_ptr(this_ptr);
33567         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33569         this_ptr_conv.is_owned = false;
33570         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33571         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
33572         return ret_arr;
33573 }
33574
33575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33576         LDKFundingCreated this_ptr_conv;
33577         this_ptr_conv.inner = untag_ptr(this_ptr);
33578         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33580         this_ptr_conv.is_owned = false;
33581         LDKThirtyTwoBytes val_ref;
33582         CHECK((*env)->GetArrayLength(env, val) == 32);
33583         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33584         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
33585 }
33586
33587 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
33588         LDKFundingCreated this_ptr_conv;
33589         this_ptr_conv.inner = untag_ptr(this_ptr);
33590         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33592         this_ptr_conv.is_owned = false;
33593         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33594         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
33595         return ret_arr;
33596 }
33597
33598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33599         LDKFundingCreated this_ptr_conv;
33600         this_ptr_conv.inner = untag_ptr(this_ptr);
33601         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33603         this_ptr_conv.is_owned = false;
33604         LDKThirtyTwoBytes val_ref;
33605         CHECK((*env)->GetArrayLength(env, val) == 32);
33606         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33607         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
33608 }
33609
33610 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
33611         LDKFundingCreated this_ptr_conv;
33612         this_ptr_conv.inner = untag_ptr(this_ptr);
33613         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33615         this_ptr_conv.is_owned = false;
33616         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
33617         return ret_conv;
33618 }
33619
33620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
33621         LDKFundingCreated this_ptr_conv;
33622         this_ptr_conv.inner = untag_ptr(this_ptr);
33623         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33625         this_ptr_conv.is_owned = false;
33626         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
33627 }
33628
33629 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33630         LDKFundingCreated this_ptr_conv;
33631         this_ptr_conv.inner = untag_ptr(this_ptr);
33632         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33634         this_ptr_conv.is_owned = false;
33635         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33636         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
33637         return ret_arr;
33638 }
33639
33640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33641         LDKFundingCreated this_ptr_conv;
33642         this_ptr_conv.inner = untag_ptr(this_ptr);
33643         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33645         this_ptr_conv.is_owned = false;
33646         LDKSignature val_ref;
33647         CHECK((*env)->GetArrayLength(env, val) == 64);
33648         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33649         FundingCreated_set_signature(&this_ptr_conv, val_ref);
33650 }
33651
33652 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) {
33653         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
33654         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
33655         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
33656         LDKThirtyTwoBytes funding_txid_arg_ref;
33657         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
33658         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
33659         LDKSignature signature_arg_ref;
33660         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33661         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33662         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
33663         int64_t ret_ref = 0;
33664         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33665         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33666         return ret_ref;
33667 }
33668
33669 static inline uint64_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
33670         LDKFundingCreated ret_var = FundingCreated_clone(arg);
33671         int64_t ret_ref = 0;
33672         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33673         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33674         return ret_ref;
33675 }
33676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33677         LDKFundingCreated arg_conv;
33678         arg_conv.inner = untag_ptr(arg);
33679         arg_conv.is_owned = ptr_is_owned(arg);
33680         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33681         arg_conv.is_owned = false;
33682         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
33683         return ret_conv;
33684 }
33685
33686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33687         LDKFundingCreated orig_conv;
33688         orig_conv.inner = untag_ptr(orig);
33689         orig_conv.is_owned = ptr_is_owned(orig);
33690         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33691         orig_conv.is_owned = false;
33692         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
33693         int64_t ret_ref = 0;
33694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33695         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33696         return ret_ref;
33697 }
33698
33699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33700         LDKFundingSigned this_obj_conv;
33701         this_obj_conv.inner = untag_ptr(this_obj);
33702         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33704         FundingSigned_free(this_obj_conv);
33705 }
33706
33707 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33708         LDKFundingSigned this_ptr_conv;
33709         this_ptr_conv.inner = untag_ptr(this_ptr);
33710         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33712         this_ptr_conv.is_owned = false;
33713         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33714         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
33715         return ret_arr;
33716 }
33717
33718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33719         LDKFundingSigned this_ptr_conv;
33720         this_ptr_conv.inner = untag_ptr(this_ptr);
33721         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33723         this_ptr_conv.is_owned = false;
33724         LDKThirtyTwoBytes val_ref;
33725         CHECK((*env)->GetArrayLength(env, val) == 32);
33726         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33727         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
33728 }
33729
33730 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
33731         LDKFundingSigned this_ptr_conv;
33732         this_ptr_conv.inner = untag_ptr(this_ptr);
33733         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33735         this_ptr_conv.is_owned = false;
33736         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33737         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
33738         return ret_arr;
33739 }
33740
33741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33742         LDKFundingSigned this_ptr_conv;
33743         this_ptr_conv.inner = untag_ptr(this_ptr);
33744         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33746         this_ptr_conv.is_owned = false;
33747         LDKSignature val_ref;
33748         CHECK((*env)->GetArrayLength(env, val) == 64);
33749         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33750         FundingSigned_set_signature(&this_ptr_conv, val_ref);
33751 }
33752
33753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
33754         LDKThirtyTwoBytes channel_id_arg_ref;
33755         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33756         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33757         LDKSignature signature_arg_ref;
33758         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
33759         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
33760         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
33761         int64_t ret_ref = 0;
33762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33763         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33764         return ret_ref;
33765 }
33766
33767 static inline uint64_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
33768         LDKFundingSigned ret_var = FundingSigned_clone(arg);
33769         int64_t ret_ref = 0;
33770         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33771         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33772         return ret_ref;
33773 }
33774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33775         LDKFundingSigned arg_conv;
33776         arg_conv.inner = untag_ptr(arg);
33777         arg_conv.is_owned = ptr_is_owned(arg);
33778         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33779         arg_conv.is_owned = false;
33780         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
33781         return ret_conv;
33782 }
33783
33784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33785         LDKFundingSigned orig_conv;
33786         orig_conv.inner = untag_ptr(orig);
33787         orig_conv.is_owned = ptr_is_owned(orig);
33788         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33789         orig_conv.is_owned = false;
33790         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
33791         int64_t ret_ref = 0;
33792         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33793         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33794         return ret_ref;
33795 }
33796
33797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33798         LDKChannelReady this_obj_conv;
33799         this_obj_conv.inner = untag_ptr(this_obj);
33800         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33802         ChannelReady_free(this_obj_conv);
33803 }
33804
33805 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33806         LDKChannelReady this_ptr_conv;
33807         this_ptr_conv.inner = untag_ptr(this_ptr);
33808         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33810         this_ptr_conv.is_owned = false;
33811         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33812         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReady_get_channel_id(&this_ptr_conv));
33813         return ret_arr;
33814 }
33815
33816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33817         LDKChannelReady this_ptr_conv;
33818         this_ptr_conv.inner = untag_ptr(this_ptr);
33819         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33821         this_ptr_conv.is_owned = false;
33822         LDKThirtyTwoBytes val_ref;
33823         CHECK((*env)->GetArrayLength(env, val) == 32);
33824         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33825         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
33826 }
33827
33828 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
33829         LDKChannelReady this_ptr_conv;
33830         this_ptr_conv.inner = untag_ptr(this_ptr);
33831         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33833         this_ptr_conv.is_owned = false;
33834         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33835         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
33836         return ret_arr;
33837 }
33838
33839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33840         LDKChannelReady this_ptr_conv;
33841         this_ptr_conv.inner = untag_ptr(this_ptr);
33842         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33844         this_ptr_conv.is_owned = false;
33845         LDKPublicKey val_ref;
33846         CHECK((*env)->GetArrayLength(env, val) == 33);
33847         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
33848         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
33849 }
33850
33851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
33852         LDKChannelReady this_ptr_conv;
33853         this_ptr_conv.inner = untag_ptr(this_ptr);
33854         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33856         this_ptr_conv.is_owned = false;
33857         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
33858         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
33859         int64_t ret_ref = tag_ptr(ret_copy, true);
33860         return ret_ref;
33861 }
33862
33863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33864         LDKChannelReady this_ptr_conv;
33865         this_ptr_conv.inner = untag_ptr(this_ptr);
33866         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33868         this_ptr_conv.is_owned = false;
33869         void* val_ptr = untag_ptr(val);
33870         CHECK_ACCESS(val_ptr);
33871         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
33872         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
33873         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
33874 }
33875
33876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg, int64_t short_channel_id_alias_arg) {
33877         LDKThirtyTwoBytes channel_id_arg_ref;
33878         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33879         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33880         LDKPublicKey next_per_commitment_point_arg_ref;
33881         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
33882         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
33883         void* short_channel_id_alias_arg_ptr = untag_ptr(short_channel_id_alias_arg);
33884         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
33885         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
33886         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_alias_arg));
33887         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
33888         int64_t ret_ref = 0;
33889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33890         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33891         return ret_ref;
33892 }
33893
33894 static inline uint64_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
33895         LDKChannelReady ret_var = ChannelReady_clone(arg);
33896         int64_t ret_ref = 0;
33897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33898         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33899         return ret_ref;
33900 }
33901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33902         LDKChannelReady arg_conv;
33903         arg_conv.inner = untag_ptr(arg);
33904         arg_conv.is_owned = ptr_is_owned(arg);
33905         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33906         arg_conv.is_owned = false;
33907         int64_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
33908         return ret_conv;
33909 }
33910
33911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33912         LDKChannelReady orig_conv;
33913         orig_conv.inner = untag_ptr(orig);
33914         orig_conv.is_owned = ptr_is_owned(orig);
33915         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33916         orig_conv.is_owned = false;
33917         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
33918         int64_t ret_ref = 0;
33919         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33920         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33921         return ret_ref;
33922 }
33923
33924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33925         LDKShutdown this_obj_conv;
33926         this_obj_conv.inner = untag_ptr(this_obj);
33927         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33929         Shutdown_free(this_obj_conv);
33930 }
33931
33932 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
33933         LDKShutdown this_ptr_conv;
33934         this_ptr_conv.inner = untag_ptr(this_ptr);
33935         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33937         this_ptr_conv.is_owned = false;
33938         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33939         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
33940         return ret_arr;
33941 }
33942
33943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33944         LDKShutdown this_ptr_conv;
33945         this_ptr_conv.inner = untag_ptr(this_ptr);
33946         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33948         this_ptr_conv.is_owned = false;
33949         LDKThirtyTwoBytes val_ref;
33950         CHECK((*env)->GetArrayLength(env, val) == 32);
33951         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33952         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
33953 }
33954
33955 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
33956         LDKShutdown this_ptr_conv;
33957         this_ptr_conv.inner = untag_ptr(this_ptr);
33958         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33960         this_ptr_conv.is_owned = false;
33961         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
33962         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33963         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33964         return ret_arr;
33965 }
33966
33967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33968         LDKShutdown this_ptr_conv;
33969         this_ptr_conv.inner = untag_ptr(this_ptr);
33970         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33972         this_ptr_conv.is_owned = false;
33973         LDKCVec_u8Z val_ref;
33974         val_ref.datalen = (*env)->GetArrayLength(env, val);
33975         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
33976         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
33977         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
33978 }
33979
33980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
33981         LDKThirtyTwoBytes channel_id_arg_ref;
33982         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
33983         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
33984         LDKCVec_u8Z scriptpubkey_arg_ref;
33985         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
33986         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
33987         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
33988         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
33989         int64_t ret_ref = 0;
33990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33991         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33992         return ret_ref;
33993 }
33994
33995 static inline uint64_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
33996         LDKShutdown ret_var = Shutdown_clone(arg);
33997         int64_t ret_ref = 0;
33998         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33999         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34000         return ret_ref;
34001 }
34002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34003         LDKShutdown arg_conv;
34004         arg_conv.inner = untag_ptr(arg);
34005         arg_conv.is_owned = ptr_is_owned(arg);
34006         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34007         arg_conv.is_owned = false;
34008         int64_t ret_conv = Shutdown_clone_ptr(&arg_conv);
34009         return ret_conv;
34010 }
34011
34012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34013         LDKShutdown orig_conv;
34014         orig_conv.inner = untag_ptr(orig);
34015         orig_conv.is_owned = ptr_is_owned(orig);
34016         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34017         orig_conv.is_owned = false;
34018         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
34019         int64_t ret_ref = 0;
34020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34021         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34022         return ret_ref;
34023 }
34024
34025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34026         LDKClosingSignedFeeRange this_obj_conv;
34027         this_obj_conv.inner = untag_ptr(this_obj);
34028         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34030         ClosingSignedFeeRange_free(this_obj_conv);
34031 }
34032
34033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
34034         LDKClosingSignedFeeRange this_ptr_conv;
34035         this_ptr_conv.inner = untag_ptr(this_ptr);
34036         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34038         this_ptr_conv.is_owned = false;
34039         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
34040         return ret_conv;
34041 }
34042
34043 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34044         LDKClosingSignedFeeRange this_ptr_conv;
34045         this_ptr_conv.inner = untag_ptr(this_ptr);
34046         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34048         this_ptr_conv.is_owned = false;
34049         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
34050 }
34051
34052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
34053         LDKClosingSignedFeeRange this_ptr_conv;
34054         this_ptr_conv.inner = untag_ptr(this_ptr);
34055         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34057         this_ptr_conv.is_owned = false;
34058         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
34059         return ret_conv;
34060 }
34061
34062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34063         LDKClosingSignedFeeRange this_ptr_conv;
34064         this_ptr_conv.inner = untag_ptr(this_ptr);
34065         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34067         this_ptr_conv.is_owned = false;
34068         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
34069 }
34070
34071 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) {
34072         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
34073         int64_t ret_ref = 0;
34074         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34075         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34076         return ret_ref;
34077 }
34078
34079 static inline uint64_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
34080         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
34081         int64_t ret_ref = 0;
34082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34083         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34084         return ret_ref;
34085 }
34086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34087         LDKClosingSignedFeeRange arg_conv;
34088         arg_conv.inner = untag_ptr(arg);
34089         arg_conv.is_owned = ptr_is_owned(arg);
34090         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34091         arg_conv.is_owned = false;
34092         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
34093         return ret_conv;
34094 }
34095
34096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34097         LDKClosingSignedFeeRange orig_conv;
34098         orig_conv.inner = untag_ptr(orig);
34099         orig_conv.is_owned = ptr_is_owned(orig);
34100         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34101         orig_conv.is_owned = false;
34102         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
34103         int64_t ret_ref = 0;
34104         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34105         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34106         return ret_ref;
34107 }
34108
34109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34110         LDKClosingSigned this_obj_conv;
34111         this_obj_conv.inner = untag_ptr(this_obj);
34112         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34114         ClosingSigned_free(this_obj_conv);
34115 }
34116
34117 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34118         LDKClosingSigned this_ptr_conv;
34119         this_ptr_conv.inner = untag_ptr(this_ptr);
34120         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34122         this_ptr_conv.is_owned = false;
34123         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34124         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
34125         return ret_arr;
34126 }
34127
34128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34129         LDKClosingSigned this_ptr_conv;
34130         this_ptr_conv.inner = untag_ptr(this_ptr);
34131         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34133         this_ptr_conv.is_owned = false;
34134         LDKThirtyTwoBytes val_ref;
34135         CHECK((*env)->GetArrayLength(env, val) == 32);
34136         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34137         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
34138 }
34139
34140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
34141         LDKClosingSigned this_ptr_conv;
34142         this_ptr_conv.inner = untag_ptr(this_ptr);
34143         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34145         this_ptr_conv.is_owned = false;
34146         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
34147         return ret_conv;
34148 }
34149
34150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34151         LDKClosingSigned this_ptr_conv;
34152         this_ptr_conv.inner = untag_ptr(this_ptr);
34153         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34155         this_ptr_conv.is_owned = false;
34156         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
34157 }
34158
34159 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34160         LDKClosingSigned this_ptr_conv;
34161         this_ptr_conv.inner = untag_ptr(this_ptr);
34162         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34164         this_ptr_conv.is_owned = false;
34165         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34166         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
34167         return ret_arr;
34168 }
34169
34170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34171         LDKClosingSigned this_ptr_conv;
34172         this_ptr_conv.inner = untag_ptr(this_ptr);
34173         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34175         this_ptr_conv.is_owned = false;
34176         LDKSignature val_ref;
34177         CHECK((*env)->GetArrayLength(env, val) == 64);
34178         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34179         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
34180 }
34181
34182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
34183         LDKClosingSigned this_ptr_conv;
34184         this_ptr_conv.inner = untag_ptr(this_ptr);
34185         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34187         this_ptr_conv.is_owned = false;
34188         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
34189         int64_t ret_ref = 0;
34190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34191         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34192         return ret_ref;
34193 }
34194
34195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34196         LDKClosingSigned this_ptr_conv;
34197         this_ptr_conv.inner = untag_ptr(this_ptr);
34198         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34200         this_ptr_conv.is_owned = false;
34201         LDKClosingSignedFeeRange val_conv;
34202         val_conv.inner = untag_ptr(val);
34203         val_conv.is_owned = ptr_is_owned(val);
34204         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34205         val_conv = ClosingSignedFeeRange_clone(&val_conv);
34206         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
34207 }
34208
34209 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) {
34210         LDKThirtyTwoBytes channel_id_arg_ref;
34211         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34212         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34213         LDKSignature signature_arg_ref;
34214         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
34215         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
34216         LDKClosingSignedFeeRange fee_range_arg_conv;
34217         fee_range_arg_conv.inner = untag_ptr(fee_range_arg);
34218         fee_range_arg_conv.is_owned = ptr_is_owned(fee_range_arg);
34219         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
34220         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
34221         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
34222         int64_t ret_ref = 0;
34223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34224         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34225         return ret_ref;
34226 }
34227
34228 static inline uint64_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
34229         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
34230         int64_t ret_ref = 0;
34231         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34232         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34233         return ret_ref;
34234 }
34235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34236         LDKClosingSigned arg_conv;
34237         arg_conv.inner = untag_ptr(arg);
34238         arg_conv.is_owned = ptr_is_owned(arg);
34239         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34240         arg_conv.is_owned = false;
34241         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
34242         return ret_conv;
34243 }
34244
34245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34246         LDKClosingSigned orig_conv;
34247         orig_conv.inner = untag_ptr(orig);
34248         orig_conv.is_owned = ptr_is_owned(orig);
34249         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34250         orig_conv.is_owned = false;
34251         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
34252         int64_t ret_ref = 0;
34253         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34254         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34255         return ret_ref;
34256 }
34257
34258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34259         LDKUpdateAddHTLC this_obj_conv;
34260         this_obj_conv.inner = untag_ptr(this_obj);
34261         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34263         UpdateAddHTLC_free(this_obj_conv);
34264 }
34265
34266 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34267         LDKUpdateAddHTLC this_ptr_conv;
34268         this_ptr_conv.inner = untag_ptr(this_ptr);
34269         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34271         this_ptr_conv.is_owned = false;
34272         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34273         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
34274         return ret_arr;
34275 }
34276
34277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34278         LDKUpdateAddHTLC this_ptr_conv;
34279         this_ptr_conv.inner = untag_ptr(this_ptr);
34280         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34282         this_ptr_conv.is_owned = false;
34283         LDKThirtyTwoBytes val_ref;
34284         CHECK((*env)->GetArrayLength(env, val) == 32);
34285         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34286         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
34287 }
34288
34289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34290         LDKUpdateAddHTLC this_ptr_conv;
34291         this_ptr_conv.inner = untag_ptr(this_ptr);
34292         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34294         this_ptr_conv.is_owned = false;
34295         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
34296         return ret_conv;
34297 }
34298
34299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34300         LDKUpdateAddHTLC this_ptr_conv;
34301         this_ptr_conv.inner = untag_ptr(this_ptr);
34302         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34304         this_ptr_conv.is_owned = false;
34305         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
34306 }
34307
34308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
34309         LDKUpdateAddHTLC this_ptr_conv;
34310         this_ptr_conv.inner = untag_ptr(this_ptr);
34311         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34313         this_ptr_conv.is_owned = false;
34314         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
34315         return ret_conv;
34316 }
34317
34318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34319         LDKUpdateAddHTLC this_ptr_conv;
34320         this_ptr_conv.inner = untag_ptr(this_ptr);
34321         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34323         this_ptr_conv.is_owned = false;
34324         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
34325 }
34326
34327 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34328         LDKUpdateAddHTLC this_ptr_conv;
34329         this_ptr_conv.inner = untag_ptr(this_ptr);
34330         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34332         this_ptr_conv.is_owned = false;
34333         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34334         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
34335         return ret_arr;
34336 }
34337
34338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34339         LDKUpdateAddHTLC this_ptr_conv;
34340         this_ptr_conv.inner = untag_ptr(this_ptr);
34341         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34343         this_ptr_conv.is_owned = false;
34344         LDKThirtyTwoBytes val_ref;
34345         CHECK((*env)->GetArrayLength(env, val) == 32);
34346         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34347         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
34348 }
34349
34350 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
34351         LDKUpdateAddHTLC this_ptr_conv;
34352         this_ptr_conv.inner = untag_ptr(this_ptr);
34353         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34355         this_ptr_conv.is_owned = false;
34356         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
34357         return ret_conv;
34358 }
34359
34360 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34361         LDKUpdateAddHTLC this_ptr_conv;
34362         this_ptr_conv.inner = untag_ptr(this_ptr);
34363         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34365         this_ptr_conv.is_owned = false;
34366         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
34367 }
34368
34369 static inline uint64_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
34370         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
34371         int64_t ret_ref = 0;
34372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34373         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34374         return ret_ref;
34375 }
34376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34377         LDKUpdateAddHTLC arg_conv;
34378         arg_conv.inner = untag_ptr(arg);
34379         arg_conv.is_owned = ptr_is_owned(arg);
34380         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34381         arg_conv.is_owned = false;
34382         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
34383         return ret_conv;
34384 }
34385
34386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34387         LDKUpdateAddHTLC orig_conv;
34388         orig_conv.inner = untag_ptr(orig);
34389         orig_conv.is_owned = ptr_is_owned(orig);
34390         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34391         orig_conv.is_owned = false;
34392         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
34393         int64_t ret_ref = 0;
34394         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34395         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34396         return ret_ref;
34397 }
34398
34399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34400         LDKOnionMessage this_obj_conv;
34401         this_obj_conv.inner = untag_ptr(this_obj);
34402         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34404         OnionMessage_free(this_obj_conv);
34405 }
34406
34407 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OnionMessage_1get_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34408         LDKOnionMessage this_ptr_conv;
34409         this_ptr_conv.inner = untag_ptr(this_ptr);
34410         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34412         this_ptr_conv.is_owned = false;
34413         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34414         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OnionMessage_get_blinding_point(&this_ptr_conv).compressed_form);
34415         return ret_arr;
34416 }
34417
34418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessage_1set_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34419         LDKOnionMessage this_ptr_conv;
34420         this_ptr_conv.inner = untag_ptr(this_ptr);
34421         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34423         this_ptr_conv.is_owned = false;
34424         LDKPublicKey val_ref;
34425         CHECK((*env)->GetArrayLength(env, val) == 33);
34426         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34427         OnionMessage_set_blinding_point(&this_ptr_conv, val_ref);
34428 }
34429
34430 static inline uint64_t OnionMessage_clone_ptr(LDKOnionMessage *NONNULL_PTR arg) {
34431         LDKOnionMessage ret_var = OnionMessage_clone(arg);
34432         int64_t ret_ref = 0;
34433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34434         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34435         return ret_ref;
34436 }
34437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34438         LDKOnionMessage arg_conv;
34439         arg_conv.inner = untag_ptr(arg);
34440         arg_conv.is_owned = ptr_is_owned(arg);
34441         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34442         arg_conv.is_owned = false;
34443         int64_t ret_conv = OnionMessage_clone_ptr(&arg_conv);
34444         return ret_conv;
34445 }
34446
34447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34448         LDKOnionMessage orig_conv;
34449         orig_conv.inner = untag_ptr(orig);
34450         orig_conv.is_owned = ptr_is_owned(orig);
34451         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34452         orig_conv.is_owned = false;
34453         LDKOnionMessage ret_var = OnionMessage_clone(&orig_conv);
34454         int64_t ret_ref = 0;
34455         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34456         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34457         return ret_ref;
34458 }
34459
34460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34461         LDKUpdateFulfillHTLC this_obj_conv;
34462         this_obj_conv.inner = untag_ptr(this_obj);
34463         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34465         UpdateFulfillHTLC_free(this_obj_conv);
34466 }
34467
34468 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34469         LDKUpdateFulfillHTLC this_ptr_conv;
34470         this_ptr_conv.inner = untag_ptr(this_ptr);
34471         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34473         this_ptr_conv.is_owned = false;
34474         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34475         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
34476         return ret_arr;
34477 }
34478
34479 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34480         LDKUpdateFulfillHTLC this_ptr_conv;
34481         this_ptr_conv.inner = untag_ptr(this_ptr);
34482         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34484         this_ptr_conv.is_owned = false;
34485         LDKThirtyTwoBytes val_ref;
34486         CHECK((*env)->GetArrayLength(env, val) == 32);
34487         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34488         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
34489 }
34490
34491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34492         LDKUpdateFulfillHTLC this_ptr_conv;
34493         this_ptr_conv.inner = untag_ptr(this_ptr);
34494         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34496         this_ptr_conv.is_owned = false;
34497         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
34498         return ret_conv;
34499 }
34500
34501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34502         LDKUpdateFulfillHTLC this_ptr_conv;
34503         this_ptr_conv.inner = untag_ptr(this_ptr);
34504         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34506         this_ptr_conv.is_owned = false;
34507         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
34508 }
34509
34510 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
34511         LDKUpdateFulfillHTLC this_ptr_conv;
34512         this_ptr_conv.inner = untag_ptr(this_ptr);
34513         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34515         this_ptr_conv.is_owned = false;
34516         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34517         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
34518         return ret_arr;
34519 }
34520
34521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34522         LDKUpdateFulfillHTLC this_ptr_conv;
34523         this_ptr_conv.inner = untag_ptr(this_ptr);
34524         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34526         this_ptr_conv.is_owned = false;
34527         LDKThirtyTwoBytes val_ref;
34528         CHECK((*env)->GetArrayLength(env, val) == 32);
34529         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34530         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
34531 }
34532
34533 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) {
34534         LDKThirtyTwoBytes channel_id_arg_ref;
34535         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34536         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34537         LDKThirtyTwoBytes payment_preimage_arg_ref;
34538         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
34539         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
34540         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
34541         int64_t ret_ref = 0;
34542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34543         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34544         return ret_ref;
34545 }
34546
34547 static inline uint64_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
34548         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
34549         int64_t ret_ref = 0;
34550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34551         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34552         return ret_ref;
34553 }
34554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34555         LDKUpdateFulfillHTLC arg_conv;
34556         arg_conv.inner = untag_ptr(arg);
34557         arg_conv.is_owned = ptr_is_owned(arg);
34558         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34559         arg_conv.is_owned = false;
34560         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
34561         return ret_conv;
34562 }
34563
34564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34565         LDKUpdateFulfillHTLC orig_conv;
34566         orig_conv.inner = untag_ptr(orig);
34567         orig_conv.is_owned = ptr_is_owned(orig);
34568         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34569         orig_conv.is_owned = false;
34570         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
34571         int64_t ret_ref = 0;
34572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34573         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34574         return ret_ref;
34575 }
34576
34577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34578         LDKUpdateFailHTLC this_obj_conv;
34579         this_obj_conv.inner = untag_ptr(this_obj);
34580         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34582         UpdateFailHTLC_free(this_obj_conv);
34583 }
34584
34585 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34586         LDKUpdateFailHTLC this_ptr_conv;
34587         this_ptr_conv.inner = untag_ptr(this_ptr);
34588         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34590         this_ptr_conv.is_owned = false;
34591         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34592         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
34593         return ret_arr;
34594 }
34595
34596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34597         LDKUpdateFailHTLC this_ptr_conv;
34598         this_ptr_conv.inner = untag_ptr(this_ptr);
34599         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34601         this_ptr_conv.is_owned = false;
34602         LDKThirtyTwoBytes val_ref;
34603         CHECK((*env)->GetArrayLength(env, val) == 32);
34604         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34605         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
34606 }
34607
34608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34609         LDKUpdateFailHTLC this_ptr_conv;
34610         this_ptr_conv.inner = untag_ptr(this_ptr);
34611         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34613         this_ptr_conv.is_owned = false;
34614         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
34615         return ret_conv;
34616 }
34617
34618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34619         LDKUpdateFailHTLC this_ptr_conv;
34620         this_ptr_conv.inner = untag_ptr(this_ptr);
34621         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34623         this_ptr_conv.is_owned = false;
34624         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
34625 }
34626
34627 static inline uint64_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
34628         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
34629         int64_t ret_ref = 0;
34630         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34631         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34632         return ret_ref;
34633 }
34634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34635         LDKUpdateFailHTLC arg_conv;
34636         arg_conv.inner = untag_ptr(arg);
34637         arg_conv.is_owned = ptr_is_owned(arg);
34638         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34639         arg_conv.is_owned = false;
34640         int64_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
34641         return ret_conv;
34642 }
34643
34644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34645         LDKUpdateFailHTLC orig_conv;
34646         orig_conv.inner = untag_ptr(orig);
34647         orig_conv.is_owned = ptr_is_owned(orig);
34648         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34649         orig_conv.is_owned = false;
34650         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
34651         int64_t ret_ref = 0;
34652         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34653         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34654         return ret_ref;
34655 }
34656
34657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34658         LDKUpdateFailMalformedHTLC this_obj_conv;
34659         this_obj_conv.inner = untag_ptr(this_obj);
34660         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34662         UpdateFailMalformedHTLC_free(this_obj_conv);
34663 }
34664
34665 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34666         LDKUpdateFailMalformedHTLC this_ptr_conv;
34667         this_ptr_conv.inner = untag_ptr(this_ptr);
34668         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34670         this_ptr_conv.is_owned = false;
34671         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34672         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
34673         return ret_arr;
34674 }
34675
34676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34677         LDKUpdateFailMalformedHTLC this_ptr_conv;
34678         this_ptr_conv.inner = untag_ptr(this_ptr);
34679         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34681         this_ptr_conv.is_owned = false;
34682         LDKThirtyTwoBytes val_ref;
34683         CHECK((*env)->GetArrayLength(env, val) == 32);
34684         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34685         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
34686 }
34687
34688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34689         LDKUpdateFailMalformedHTLC this_ptr_conv;
34690         this_ptr_conv.inner = untag_ptr(this_ptr);
34691         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34693         this_ptr_conv.is_owned = false;
34694         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
34695         return ret_conv;
34696 }
34697
34698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34699         LDKUpdateFailMalformedHTLC this_ptr_conv;
34700         this_ptr_conv.inner = untag_ptr(this_ptr);
34701         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34703         this_ptr_conv.is_owned = false;
34704         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
34705 }
34706
34707 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
34708         LDKUpdateFailMalformedHTLC this_ptr_conv;
34709         this_ptr_conv.inner = untag_ptr(this_ptr);
34710         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34712         this_ptr_conv.is_owned = false;
34713         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
34714         return ret_conv;
34715 }
34716
34717 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34718         LDKUpdateFailMalformedHTLC this_ptr_conv;
34719         this_ptr_conv.inner = untag_ptr(this_ptr);
34720         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34722         this_ptr_conv.is_owned = false;
34723         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
34724 }
34725
34726 static inline uint64_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
34727         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
34728         int64_t ret_ref = 0;
34729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34730         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34731         return ret_ref;
34732 }
34733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34734         LDKUpdateFailMalformedHTLC arg_conv;
34735         arg_conv.inner = untag_ptr(arg);
34736         arg_conv.is_owned = ptr_is_owned(arg);
34737         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34738         arg_conv.is_owned = false;
34739         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
34740         return ret_conv;
34741 }
34742
34743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34744         LDKUpdateFailMalformedHTLC orig_conv;
34745         orig_conv.inner = untag_ptr(orig);
34746         orig_conv.is_owned = ptr_is_owned(orig);
34747         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34748         orig_conv.is_owned = false;
34749         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
34750         int64_t ret_ref = 0;
34751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34752         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34753         return ret_ref;
34754 }
34755
34756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34757         LDKCommitmentSigned this_obj_conv;
34758         this_obj_conv.inner = untag_ptr(this_obj);
34759         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34761         CommitmentSigned_free(this_obj_conv);
34762 }
34763
34764 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34765         LDKCommitmentSigned this_ptr_conv;
34766         this_ptr_conv.inner = untag_ptr(this_ptr);
34767         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34769         this_ptr_conv.is_owned = false;
34770         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34771         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
34772         return ret_arr;
34773 }
34774
34775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34776         LDKCommitmentSigned this_ptr_conv;
34777         this_ptr_conv.inner = untag_ptr(this_ptr);
34778         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34780         this_ptr_conv.is_owned = false;
34781         LDKThirtyTwoBytes val_ref;
34782         CHECK((*env)->GetArrayLength(env, val) == 32);
34783         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34784         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
34785 }
34786
34787 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
34788         LDKCommitmentSigned this_ptr_conv;
34789         this_ptr_conv.inner = untag_ptr(this_ptr);
34790         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34792         this_ptr_conv.is_owned = false;
34793         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
34794         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
34795         return ret_arr;
34796 }
34797
34798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34799         LDKCommitmentSigned this_ptr_conv;
34800         this_ptr_conv.inner = untag_ptr(this_ptr);
34801         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34803         this_ptr_conv.is_owned = false;
34804         LDKSignature val_ref;
34805         CHECK((*env)->GetArrayLength(env, val) == 64);
34806         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
34807         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
34808 }
34809
34810 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr) {
34811         LDKCommitmentSigned this_ptr_conv;
34812         this_ptr_conv.inner = untag_ptr(this_ptr);
34813         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34815         this_ptr_conv.is_owned = false;
34816         LDKCVec_SignatureZ ret_var = CommitmentSigned_get_htlc_signatures(&this_ptr_conv);
34817         jobjectArray ret_arr = NULL;
34818         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
34819         ;
34820         for (size_t i = 0; i < ret_var.datalen; i++) {
34821                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
34822                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
34823                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
34824         }
34825         
34826         FREE(ret_var.data);
34827         return ret_arr;
34828 }
34829
34830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
34831         LDKCommitmentSigned this_ptr_conv;
34832         this_ptr_conv.inner = untag_ptr(this_ptr);
34833         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34835         this_ptr_conv.is_owned = false;
34836         LDKCVec_SignatureZ val_constr;
34837         val_constr.datalen = (*env)->GetArrayLength(env, val);
34838         if (val_constr.datalen > 0)
34839                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
34840         else
34841                 val_constr.data = NULL;
34842         for (size_t i = 0; i < val_constr.datalen; i++) {
34843                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
34844                 LDKSignature val_conv_8_ref;
34845                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
34846                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
34847                 val_constr.data[i] = val_conv_8_ref;
34848         }
34849         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
34850 }
34851
34852 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) {
34853         LDKThirtyTwoBytes channel_id_arg_ref;
34854         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34855         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34856         LDKSignature signature_arg_ref;
34857         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
34858         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
34859         LDKCVec_SignatureZ htlc_signatures_arg_constr;
34860         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
34861         if (htlc_signatures_arg_constr.datalen > 0)
34862                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
34863         else
34864                 htlc_signatures_arg_constr.data = NULL;
34865         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
34866                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
34867                 LDKSignature htlc_signatures_arg_conv_8_ref;
34868                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
34869                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
34870                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
34871         }
34872         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
34873         int64_t ret_ref = 0;
34874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34875         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34876         return ret_ref;
34877 }
34878
34879 static inline uint64_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
34880         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
34881         int64_t ret_ref = 0;
34882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34883         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34884         return ret_ref;
34885 }
34886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34887         LDKCommitmentSigned arg_conv;
34888         arg_conv.inner = untag_ptr(arg);
34889         arg_conv.is_owned = ptr_is_owned(arg);
34890         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34891         arg_conv.is_owned = false;
34892         int64_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
34893         return ret_conv;
34894 }
34895
34896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34897         LDKCommitmentSigned orig_conv;
34898         orig_conv.inner = untag_ptr(orig);
34899         orig_conv.is_owned = ptr_is_owned(orig);
34900         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34901         orig_conv.is_owned = false;
34902         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
34903         int64_t ret_ref = 0;
34904         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34905         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34906         return ret_ref;
34907 }
34908
34909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34910         LDKRevokeAndACK this_obj_conv;
34911         this_obj_conv.inner = untag_ptr(this_obj);
34912         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34914         RevokeAndACK_free(this_obj_conv);
34915 }
34916
34917 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34918         LDKRevokeAndACK this_ptr_conv;
34919         this_ptr_conv.inner = untag_ptr(this_ptr);
34920         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34922         this_ptr_conv.is_owned = false;
34923         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34924         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
34925         return ret_arr;
34926 }
34927
34928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34929         LDKRevokeAndACK this_ptr_conv;
34930         this_ptr_conv.inner = untag_ptr(this_ptr);
34931         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34933         this_ptr_conv.is_owned = false;
34934         LDKThirtyTwoBytes val_ref;
34935         CHECK((*env)->GetArrayLength(env, val) == 32);
34936         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34937         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
34938 }
34939
34940 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
34941         LDKRevokeAndACK this_ptr_conv;
34942         this_ptr_conv.inner = untag_ptr(this_ptr);
34943         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34945         this_ptr_conv.is_owned = false;
34946         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34947         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
34948         return ret_arr;
34949 }
34950
34951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34952         LDKRevokeAndACK this_ptr_conv;
34953         this_ptr_conv.inner = untag_ptr(this_ptr);
34954         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34956         this_ptr_conv.is_owned = false;
34957         LDKThirtyTwoBytes val_ref;
34958         CHECK((*env)->GetArrayLength(env, val) == 32);
34959         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34960         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
34961 }
34962
34963 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34964         LDKRevokeAndACK this_ptr_conv;
34965         this_ptr_conv.inner = untag_ptr(this_ptr);
34966         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34968         this_ptr_conv.is_owned = false;
34969         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34970         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
34971         return ret_arr;
34972 }
34973
34974 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) {
34975         LDKRevokeAndACK this_ptr_conv;
34976         this_ptr_conv.inner = untag_ptr(this_ptr);
34977         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34978         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34979         this_ptr_conv.is_owned = false;
34980         LDKPublicKey val_ref;
34981         CHECK((*env)->GetArrayLength(env, val) == 33);
34982         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34983         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
34984 }
34985
34986 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) {
34987         LDKThirtyTwoBytes channel_id_arg_ref;
34988         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34989         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34990         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
34991         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
34992         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
34993         LDKPublicKey next_per_commitment_point_arg_ref;
34994         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
34995         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
34996         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
34997         int64_t ret_ref = 0;
34998         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34999         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35000         return ret_ref;
35001 }
35002
35003 static inline uint64_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
35004         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
35005         int64_t ret_ref = 0;
35006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35007         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35008         return ret_ref;
35009 }
35010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35011         LDKRevokeAndACK arg_conv;
35012         arg_conv.inner = untag_ptr(arg);
35013         arg_conv.is_owned = ptr_is_owned(arg);
35014         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35015         arg_conv.is_owned = false;
35016         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
35017         return ret_conv;
35018 }
35019
35020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35021         LDKRevokeAndACK orig_conv;
35022         orig_conv.inner = untag_ptr(orig);
35023         orig_conv.is_owned = ptr_is_owned(orig);
35024         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35025         orig_conv.is_owned = false;
35026         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
35027         int64_t ret_ref = 0;
35028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35029         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35030         return ret_ref;
35031 }
35032
35033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35034         LDKUpdateFee this_obj_conv;
35035         this_obj_conv.inner = untag_ptr(this_obj);
35036         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35038         UpdateFee_free(this_obj_conv);
35039 }
35040
35041 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35042         LDKUpdateFee this_ptr_conv;
35043         this_ptr_conv.inner = untag_ptr(this_ptr);
35044         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35046         this_ptr_conv.is_owned = false;
35047         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35048         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
35049         return ret_arr;
35050 }
35051
35052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35053         LDKUpdateFee this_ptr_conv;
35054         this_ptr_conv.inner = untag_ptr(this_ptr);
35055         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35057         this_ptr_conv.is_owned = false;
35058         LDKThirtyTwoBytes val_ref;
35059         CHECK((*env)->GetArrayLength(env, val) == 32);
35060         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35061         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
35062 }
35063
35064 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
35065         LDKUpdateFee this_ptr_conv;
35066         this_ptr_conv.inner = untag_ptr(this_ptr);
35067         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35069         this_ptr_conv.is_owned = false;
35070         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
35071         return ret_conv;
35072 }
35073
35074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35075         LDKUpdateFee this_ptr_conv;
35076         this_ptr_conv.inner = untag_ptr(this_ptr);
35077         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35079         this_ptr_conv.is_owned = false;
35080         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
35081 }
35082
35083 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) {
35084         LDKThirtyTwoBytes channel_id_arg_ref;
35085         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
35086         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
35087         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
35088         int64_t ret_ref = 0;
35089         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35090         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35091         return ret_ref;
35092 }
35093
35094 static inline uint64_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
35095         LDKUpdateFee ret_var = UpdateFee_clone(arg);
35096         int64_t ret_ref = 0;
35097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35098         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35099         return ret_ref;
35100 }
35101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35102         LDKUpdateFee arg_conv;
35103         arg_conv.inner = untag_ptr(arg);
35104         arg_conv.is_owned = ptr_is_owned(arg);
35105         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35106         arg_conv.is_owned = false;
35107         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
35108         return ret_conv;
35109 }
35110
35111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35112         LDKUpdateFee orig_conv;
35113         orig_conv.inner = untag_ptr(orig);
35114         orig_conv.is_owned = ptr_is_owned(orig);
35115         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35116         orig_conv.is_owned = false;
35117         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
35118         int64_t ret_ref = 0;
35119         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35120         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35121         return ret_ref;
35122 }
35123
35124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35125         LDKDataLossProtect this_obj_conv;
35126         this_obj_conv.inner = untag_ptr(this_obj);
35127         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35129         DataLossProtect_free(this_obj_conv);
35130 }
35131
35132 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
35133         LDKDataLossProtect this_ptr_conv;
35134         this_ptr_conv.inner = untag_ptr(this_ptr);
35135         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35137         this_ptr_conv.is_owned = false;
35138         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35139         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
35140         return ret_arr;
35141 }
35142
35143 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) {
35144         LDKDataLossProtect this_ptr_conv;
35145         this_ptr_conv.inner = untag_ptr(this_ptr);
35146         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35148         this_ptr_conv.is_owned = false;
35149         LDKThirtyTwoBytes val_ref;
35150         CHECK((*env)->GetArrayLength(env, val) == 32);
35151         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35152         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
35153 }
35154
35155 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35156         LDKDataLossProtect this_ptr_conv;
35157         this_ptr_conv.inner = untag_ptr(this_ptr);
35158         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35160         this_ptr_conv.is_owned = false;
35161         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35162         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
35163         return ret_arr;
35164 }
35165
35166 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) {
35167         LDKDataLossProtect this_ptr_conv;
35168         this_ptr_conv.inner = untag_ptr(this_ptr);
35169         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35171         this_ptr_conv.is_owned = false;
35172         LDKPublicKey val_ref;
35173         CHECK((*env)->GetArrayLength(env, val) == 33);
35174         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35175         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
35176 }
35177
35178 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) {
35179         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
35180         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
35181         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
35182         LDKPublicKey my_current_per_commitment_point_arg_ref;
35183         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
35184         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
35185         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
35186         int64_t ret_ref = 0;
35187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35188         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35189         return ret_ref;
35190 }
35191
35192 static inline uint64_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
35193         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
35194         int64_t ret_ref = 0;
35195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35196         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35197         return ret_ref;
35198 }
35199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35200         LDKDataLossProtect arg_conv;
35201         arg_conv.inner = untag_ptr(arg);
35202         arg_conv.is_owned = ptr_is_owned(arg);
35203         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35204         arg_conv.is_owned = false;
35205         int64_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
35206         return ret_conv;
35207 }
35208
35209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35210         LDKDataLossProtect orig_conv;
35211         orig_conv.inner = untag_ptr(orig);
35212         orig_conv.is_owned = ptr_is_owned(orig);
35213         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35214         orig_conv.is_owned = false;
35215         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
35216         int64_t ret_ref = 0;
35217         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35218         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35219         return ret_ref;
35220 }
35221
35222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35223         LDKChannelReestablish this_obj_conv;
35224         this_obj_conv.inner = untag_ptr(this_obj);
35225         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35227         ChannelReestablish_free(this_obj_conv);
35228 }
35229
35230 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35231         LDKChannelReestablish this_ptr_conv;
35232         this_ptr_conv.inner = untag_ptr(this_ptr);
35233         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35235         this_ptr_conv.is_owned = false;
35236         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35237         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
35238         return ret_arr;
35239 }
35240
35241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35242         LDKChannelReestablish this_ptr_conv;
35243         this_ptr_conv.inner = untag_ptr(this_ptr);
35244         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35246         this_ptr_conv.is_owned = false;
35247         LDKThirtyTwoBytes val_ref;
35248         CHECK((*env)->GetArrayLength(env, val) == 32);
35249         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35250         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
35251 }
35252
35253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
35254         LDKChannelReestablish this_ptr_conv;
35255         this_ptr_conv.inner = untag_ptr(this_ptr);
35256         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35258         this_ptr_conv.is_owned = false;
35259         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
35260         return ret_conv;
35261 }
35262
35263 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) {
35264         LDKChannelReestablish this_ptr_conv;
35265         this_ptr_conv.inner = untag_ptr(this_ptr);
35266         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35267         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35268         this_ptr_conv.is_owned = false;
35269         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
35270 }
35271
35272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
35273         LDKChannelReestablish this_ptr_conv;
35274         this_ptr_conv.inner = untag_ptr(this_ptr);
35275         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35277         this_ptr_conv.is_owned = false;
35278         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
35279         return ret_conv;
35280 }
35281
35282 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) {
35283         LDKChannelReestablish this_ptr_conv;
35284         this_ptr_conv.inner = untag_ptr(this_ptr);
35285         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35287         this_ptr_conv.is_owned = false;
35288         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
35289 }
35290
35291 static inline uint64_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
35292         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
35293         int64_t ret_ref = 0;
35294         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35295         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35296         return ret_ref;
35297 }
35298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35299         LDKChannelReestablish arg_conv;
35300         arg_conv.inner = untag_ptr(arg);
35301         arg_conv.is_owned = ptr_is_owned(arg);
35302         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35303         arg_conv.is_owned = false;
35304         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
35305         return ret_conv;
35306 }
35307
35308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35309         LDKChannelReestablish orig_conv;
35310         orig_conv.inner = untag_ptr(orig);
35311         orig_conv.is_owned = ptr_is_owned(orig);
35312         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35313         orig_conv.is_owned = false;
35314         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
35315         int64_t ret_ref = 0;
35316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35317         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35318         return ret_ref;
35319 }
35320
35321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35322         LDKAnnouncementSignatures this_obj_conv;
35323         this_obj_conv.inner = untag_ptr(this_obj);
35324         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35326         AnnouncementSignatures_free(this_obj_conv);
35327 }
35328
35329 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35330         LDKAnnouncementSignatures this_ptr_conv;
35331         this_ptr_conv.inner = untag_ptr(this_ptr);
35332         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35334         this_ptr_conv.is_owned = false;
35335         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35336         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
35337         return ret_arr;
35338 }
35339
35340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35341         LDKAnnouncementSignatures this_ptr_conv;
35342         this_ptr_conv.inner = untag_ptr(this_ptr);
35343         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35345         this_ptr_conv.is_owned = false;
35346         LDKThirtyTwoBytes val_ref;
35347         CHECK((*env)->GetArrayLength(env, val) == 32);
35348         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35349         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
35350 }
35351
35352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35353         LDKAnnouncementSignatures this_ptr_conv;
35354         this_ptr_conv.inner = untag_ptr(this_ptr);
35355         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35357         this_ptr_conv.is_owned = false;
35358         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
35359         return ret_conv;
35360 }
35361
35362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35363         LDKAnnouncementSignatures this_ptr_conv;
35364         this_ptr_conv.inner = untag_ptr(this_ptr);
35365         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35367         this_ptr_conv.is_owned = false;
35368         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
35369 }
35370
35371 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
35372         LDKAnnouncementSignatures this_ptr_conv;
35373         this_ptr_conv.inner = untag_ptr(this_ptr);
35374         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35376         this_ptr_conv.is_owned = false;
35377         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35378         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
35379         return ret_arr;
35380 }
35381
35382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35383         LDKAnnouncementSignatures this_ptr_conv;
35384         this_ptr_conv.inner = untag_ptr(this_ptr);
35385         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35387         this_ptr_conv.is_owned = false;
35388         LDKSignature val_ref;
35389         CHECK((*env)->GetArrayLength(env, val) == 64);
35390         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35391         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
35392 }
35393
35394 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
35395         LDKAnnouncementSignatures this_ptr_conv;
35396         this_ptr_conv.inner = untag_ptr(this_ptr);
35397         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35399         this_ptr_conv.is_owned = false;
35400         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35401         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
35402         return ret_arr;
35403 }
35404
35405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35406         LDKAnnouncementSignatures this_ptr_conv;
35407         this_ptr_conv.inner = untag_ptr(this_ptr);
35408         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35410         this_ptr_conv.is_owned = false;
35411         LDKSignature val_ref;
35412         CHECK((*env)->GetArrayLength(env, val) == 64);
35413         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35414         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
35415 }
35416
35417 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) {
35418         LDKThirtyTwoBytes channel_id_arg_ref;
35419         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
35420         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
35421         LDKSignature node_signature_arg_ref;
35422         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
35423         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
35424         LDKSignature bitcoin_signature_arg_ref;
35425         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
35426         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
35427         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
35428         int64_t ret_ref = 0;
35429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35430         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35431         return ret_ref;
35432 }
35433
35434 static inline uint64_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
35435         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
35436         int64_t ret_ref = 0;
35437         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35438         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35439         return ret_ref;
35440 }
35441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35442         LDKAnnouncementSignatures arg_conv;
35443         arg_conv.inner = untag_ptr(arg);
35444         arg_conv.is_owned = ptr_is_owned(arg);
35445         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35446         arg_conv.is_owned = false;
35447         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
35448         return ret_conv;
35449 }
35450
35451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35452         LDKAnnouncementSignatures orig_conv;
35453         orig_conv.inner = untag_ptr(orig);
35454         orig_conv.is_owned = ptr_is_owned(orig);
35455         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35456         orig_conv.is_owned = false;
35457         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
35458         int64_t ret_ref = 0;
35459         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35460         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35461         return ret_ref;
35462 }
35463
35464 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
35465         if (!ptr_is_owned(this_ptr)) return;
35466         void* this_ptr_ptr = untag_ptr(this_ptr);
35467         CHECK_ACCESS(this_ptr_ptr);
35468         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
35469         FREE(untag_ptr(this_ptr));
35470         NetAddress_free(this_ptr_conv);
35471 }
35472
35473 static inline uint64_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
35474         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35475         *ret_copy = NetAddress_clone(arg);
35476         int64_t ret_ref = tag_ptr(ret_copy, true);
35477         return ret_ref;
35478 }
35479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35480         LDKNetAddress* arg_conv = (LDKNetAddress*)untag_ptr(arg);
35481         int64_t ret_conv = NetAddress_clone_ptr(arg_conv);
35482         return ret_conv;
35483 }
35484
35485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35486         LDKNetAddress* orig_conv = (LDKNetAddress*)untag_ptr(orig);
35487         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35488         *ret_copy = NetAddress_clone(orig_conv);
35489         int64_t ret_ref = tag_ptr(ret_copy, true);
35490         return ret_ref;
35491 }
35492
35493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
35494         LDKFourBytes addr_ref;
35495         CHECK((*env)->GetArrayLength(env, addr) == 4);
35496         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
35497         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35498         *ret_copy = NetAddress_ipv4(addr_ref, port);
35499         int64_t ret_ref = tag_ptr(ret_copy, true);
35500         return ret_ref;
35501 }
35502
35503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
35504         LDKSixteenBytes addr_ref;
35505         CHECK((*env)->GetArrayLength(env, addr) == 16);
35506         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
35507         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35508         *ret_copy = NetAddress_ipv6(addr_ref, port);
35509         int64_t ret_ref = tag_ptr(ret_copy, true);
35510         return ret_ref;
35511 }
35512
35513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
35514         LDKTwelveBytes a_ref;
35515         CHECK((*env)->GetArrayLength(env, a) == 12);
35516         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
35517         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35518         *ret_copy = NetAddress_onion_v2(a_ref);
35519         int64_t ret_ref = tag_ptr(ret_copy, true);
35520         return ret_ref;
35521 }
35522
35523 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) {
35524         LDKThirtyTwoBytes ed25519_pubkey_ref;
35525         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
35526         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
35527         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35528         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
35529         int64_t ret_ref = tag_ptr(ret_copy, true);
35530         return ret_ref;
35531 }
35532
35533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1hostname(JNIEnv *env, jclass clz, int64_t hostname, int16_t port) {
35534         LDKHostname hostname_conv;
35535         hostname_conv.inner = untag_ptr(hostname);
35536         hostname_conv.is_owned = ptr_is_owned(hostname);
35537         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_conv);
35538         hostname_conv = Hostname_clone(&hostname_conv);
35539         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35540         *ret_copy = NetAddress_hostname(hostname_conv, port);
35541         int64_t ret_ref = tag_ptr(ret_copy, true);
35542         return ret_ref;
35543 }
35544
35545 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
35546         LDKNetAddress* obj_conv = (LDKNetAddress*)untag_ptr(obj);
35547         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
35548         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35549         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35550         CVec_u8Z_free(ret_var);
35551         return ret_arr;
35552 }
35553
35554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35555         LDKu8slice ser_ref;
35556         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35557         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35558         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
35559         *ret_conv = NetAddress_read(ser_ref);
35560         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35561         return tag_ptr(ret_conv, true);
35562 }
35563
35564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35565         LDKUnsignedNodeAnnouncement this_obj_conv;
35566         this_obj_conv.inner = untag_ptr(this_obj);
35567         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35569         UnsignedNodeAnnouncement_free(this_obj_conv);
35570 }
35571
35572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
35573         LDKUnsignedNodeAnnouncement this_ptr_conv;
35574         this_ptr_conv.inner = untag_ptr(this_ptr);
35575         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35577         this_ptr_conv.is_owned = false;
35578         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
35579         int64_t ret_ref = 0;
35580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35581         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35582         return ret_ref;
35583 }
35584
35585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35586         LDKUnsignedNodeAnnouncement this_ptr_conv;
35587         this_ptr_conv.inner = untag_ptr(this_ptr);
35588         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35590         this_ptr_conv.is_owned = false;
35591         LDKNodeFeatures val_conv;
35592         val_conv.inner = untag_ptr(val);
35593         val_conv.is_owned = ptr_is_owned(val);
35594         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35595         val_conv = NodeFeatures_clone(&val_conv);
35596         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
35597 }
35598
35599 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
35600         LDKUnsignedNodeAnnouncement this_ptr_conv;
35601         this_ptr_conv.inner = untag_ptr(this_ptr);
35602         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35604         this_ptr_conv.is_owned = false;
35605         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
35606         return ret_conv;
35607 }
35608
35609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35610         LDKUnsignedNodeAnnouncement this_ptr_conv;
35611         this_ptr_conv.inner = untag_ptr(this_ptr);
35612         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35614         this_ptr_conv.is_owned = false;
35615         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
35616 }
35617
35618 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35619         LDKUnsignedNodeAnnouncement this_ptr_conv;
35620         this_ptr_conv.inner = untag_ptr(this_ptr);
35621         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35623         this_ptr_conv.is_owned = false;
35624         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35625         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
35626         return ret_arr;
35627 }
35628
35629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35630         LDKUnsignedNodeAnnouncement this_ptr_conv;
35631         this_ptr_conv.inner = untag_ptr(this_ptr);
35632         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35634         this_ptr_conv.is_owned = false;
35635         LDKPublicKey val_ref;
35636         CHECK((*env)->GetArrayLength(env, val) == 33);
35637         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35638         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
35639 }
35640
35641 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
35642         LDKUnsignedNodeAnnouncement this_ptr_conv;
35643         this_ptr_conv.inner = untag_ptr(this_ptr);
35644         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35646         this_ptr_conv.is_owned = false;
35647         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
35648         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
35649         return ret_arr;
35650 }
35651
35652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35653         LDKUnsignedNodeAnnouncement this_ptr_conv;
35654         this_ptr_conv.inner = untag_ptr(this_ptr);
35655         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35657         this_ptr_conv.is_owned = false;
35658         LDKThreeBytes val_ref;
35659         CHECK((*env)->GetArrayLength(env, val) == 3);
35660         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
35661         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
35662 }
35663
35664 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
35665         LDKUnsignedNodeAnnouncement this_ptr_conv;
35666         this_ptr_conv.inner = untag_ptr(this_ptr);
35667         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35669         this_ptr_conv.is_owned = false;
35670         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35671         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
35672         return ret_arr;
35673 }
35674
35675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35676         LDKUnsignedNodeAnnouncement this_ptr_conv;
35677         this_ptr_conv.inner = untag_ptr(this_ptr);
35678         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35680         this_ptr_conv.is_owned = false;
35681         LDKThirtyTwoBytes val_ref;
35682         CHECK((*env)->GetArrayLength(env, val) == 32);
35683         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35684         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
35685 }
35686
35687 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr) {
35688         LDKUnsignedNodeAnnouncement this_ptr_conv;
35689         this_ptr_conv.inner = untag_ptr(this_ptr);
35690         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35692         this_ptr_conv.is_owned = false;
35693         LDKCVec_NetAddressZ ret_var = UnsignedNodeAnnouncement_get_addresses(&this_ptr_conv);
35694         int64_tArray ret_arr = NULL;
35695         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
35696         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
35697         for (size_t m = 0; m < ret_var.datalen; m++) {
35698                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
35699                 *ret_conv_12_copy = ret_var.data[m];
35700                 int64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
35701                 ret_arr_ptr[m] = ret_conv_12_ref;
35702         }
35703         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
35704         FREE(ret_var.data);
35705         return ret_arr;
35706 }
35707
35708 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35709         LDKUnsignedNodeAnnouncement this_ptr_conv;
35710         this_ptr_conv.inner = untag_ptr(this_ptr);
35711         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35713         this_ptr_conv.is_owned = false;
35714         LDKCVec_NetAddressZ val_constr;
35715         val_constr.datalen = (*env)->GetArrayLength(env, val);
35716         if (val_constr.datalen > 0)
35717                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
35718         else
35719                 val_constr.data = NULL;
35720         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35721         for (size_t m = 0; m < val_constr.datalen; m++) {
35722                 int64_t val_conv_12 = val_vals[m];
35723                 void* val_conv_12_ptr = untag_ptr(val_conv_12);
35724                 CHECK_ACCESS(val_conv_12_ptr);
35725                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
35726                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(val_conv_12));
35727                 val_constr.data[m] = val_conv_12_conv;
35728         }
35729         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35730         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
35731 }
35732
35733 static inline uint64_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
35734         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
35735         int64_t ret_ref = 0;
35736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35737         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35738         return ret_ref;
35739 }
35740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35741         LDKUnsignedNodeAnnouncement arg_conv;
35742         arg_conv.inner = untag_ptr(arg);
35743         arg_conv.is_owned = ptr_is_owned(arg);
35744         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35745         arg_conv.is_owned = false;
35746         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
35747         return ret_conv;
35748 }
35749
35750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35751         LDKUnsignedNodeAnnouncement orig_conv;
35752         orig_conv.inner = untag_ptr(orig);
35753         orig_conv.is_owned = ptr_is_owned(orig);
35754         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35755         orig_conv.is_owned = false;
35756         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
35757         int64_t ret_ref = 0;
35758         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35759         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35760         return ret_ref;
35761 }
35762
35763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35764         LDKNodeAnnouncement this_obj_conv;
35765         this_obj_conv.inner = untag_ptr(this_obj);
35766         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35768         NodeAnnouncement_free(this_obj_conv);
35769 }
35770
35771 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
35772         LDKNodeAnnouncement this_ptr_conv;
35773         this_ptr_conv.inner = untag_ptr(this_ptr);
35774         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35776         this_ptr_conv.is_owned = false;
35777         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35778         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
35779         return ret_arr;
35780 }
35781
35782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35783         LDKNodeAnnouncement this_ptr_conv;
35784         this_ptr_conv.inner = untag_ptr(this_ptr);
35785         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35787         this_ptr_conv.is_owned = false;
35788         LDKSignature val_ref;
35789         CHECK((*env)->GetArrayLength(env, val) == 64);
35790         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35791         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
35792 }
35793
35794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
35795         LDKNodeAnnouncement this_ptr_conv;
35796         this_ptr_conv.inner = untag_ptr(this_ptr);
35797         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35799         this_ptr_conv.is_owned = false;
35800         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
35801         int64_t ret_ref = 0;
35802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35803         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35804         return ret_ref;
35805 }
35806
35807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35808         LDKNodeAnnouncement this_ptr_conv;
35809         this_ptr_conv.inner = untag_ptr(this_ptr);
35810         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35812         this_ptr_conv.is_owned = false;
35813         LDKUnsignedNodeAnnouncement val_conv;
35814         val_conv.inner = untag_ptr(val);
35815         val_conv.is_owned = ptr_is_owned(val);
35816         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35817         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
35818         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
35819 }
35820
35821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
35822         LDKSignature signature_arg_ref;
35823         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
35824         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
35825         LDKUnsignedNodeAnnouncement contents_arg_conv;
35826         contents_arg_conv.inner = untag_ptr(contents_arg);
35827         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
35828         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
35829         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
35830         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
35831         int64_t ret_ref = 0;
35832         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35833         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35834         return ret_ref;
35835 }
35836
35837 static inline uint64_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
35838         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
35839         int64_t ret_ref = 0;
35840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35841         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35842         return ret_ref;
35843 }
35844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35845         LDKNodeAnnouncement arg_conv;
35846         arg_conv.inner = untag_ptr(arg);
35847         arg_conv.is_owned = ptr_is_owned(arg);
35848         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35849         arg_conv.is_owned = false;
35850         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
35851         return ret_conv;
35852 }
35853
35854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35855         LDKNodeAnnouncement orig_conv;
35856         orig_conv.inner = untag_ptr(orig);
35857         orig_conv.is_owned = ptr_is_owned(orig);
35858         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35859         orig_conv.is_owned = false;
35860         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
35861         int64_t ret_ref = 0;
35862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35863         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35864         return ret_ref;
35865 }
35866
35867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35868         LDKUnsignedChannelAnnouncement this_obj_conv;
35869         this_obj_conv.inner = untag_ptr(this_obj);
35870         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35872         UnsignedChannelAnnouncement_free(this_obj_conv);
35873 }
35874
35875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
35876         LDKUnsignedChannelAnnouncement this_ptr_conv;
35877         this_ptr_conv.inner = untag_ptr(this_ptr);
35878         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35880         this_ptr_conv.is_owned = false;
35881         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
35882         int64_t ret_ref = 0;
35883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35884         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35885         return ret_ref;
35886 }
35887
35888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35889         LDKUnsignedChannelAnnouncement this_ptr_conv;
35890         this_ptr_conv.inner = untag_ptr(this_ptr);
35891         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35893         this_ptr_conv.is_owned = false;
35894         LDKChannelFeatures val_conv;
35895         val_conv.inner = untag_ptr(val);
35896         val_conv.is_owned = ptr_is_owned(val);
35897         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35898         val_conv = ChannelFeatures_clone(&val_conv);
35899         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
35900 }
35901
35902 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
35903         LDKUnsignedChannelAnnouncement this_ptr_conv;
35904         this_ptr_conv.inner = untag_ptr(this_ptr);
35905         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35907         this_ptr_conv.is_owned = false;
35908         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35909         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
35910         return ret_arr;
35911 }
35912
35913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35914         LDKUnsignedChannelAnnouncement this_ptr_conv;
35915         this_ptr_conv.inner = untag_ptr(this_ptr);
35916         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35918         this_ptr_conv.is_owned = false;
35919         LDKThirtyTwoBytes val_ref;
35920         CHECK((*env)->GetArrayLength(env, val) == 32);
35921         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35922         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
35923 }
35924
35925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35926         LDKUnsignedChannelAnnouncement this_ptr_conv;
35927         this_ptr_conv.inner = untag_ptr(this_ptr);
35928         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35930         this_ptr_conv.is_owned = false;
35931         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
35932         return ret_conv;
35933 }
35934
35935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35936         LDKUnsignedChannelAnnouncement this_ptr_conv;
35937         this_ptr_conv.inner = untag_ptr(this_ptr);
35938         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35940         this_ptr_conv.is_owned = false;
35941         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
35942 }
35943
35944 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
35945         LDKUnsignedChannelAnnouncement this_ptr_conv;
35946         this_ptr_conv.inner = untag_ptr(this_ptr);
35947         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35949         this_ptr_conv.is_owned = false;
35950         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35951         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
35952         return ret_arr;
35953 }
35954
35955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35956         LDKUnsignedChannelAnnouncement this_ptr_conv;
35957         this_ptr_conv.inner = untag_ptr(this_ptr);
35958         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35960         this_ptr_conv.is_owned = false;
35961         LDKPublicKey val_ref;
35962         CHECK((*env)->GetArrayLength(env, val) == 33);
35963         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35964         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
35965 }
35966
35967 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
35968         LDKUnsignedChannelAnnouncement this_ptr_conv;
35969         this_ptr_conv.inner = untag_ptr(this_ptr);
35970         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35972         this_ptr_conv.is_owned = false;
35973         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35974         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
35975         return ret_arr;
35976 }
35977
35978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35979         LDKUnsignedChannelAnnouncement this_ptr_conv;
35980         this_ptr_conv.inner = untag_ptr(this_ptr);
35981         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35983         this_ptr_conv.is_owned = false;
35984         LDKPublicKey val_ref;
35985         CHECK((*env)->GetArrayLength(env, val) == 33);
35986         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35987         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
35988 }
35989
35990 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
35991         LDKUnsignedChannelAnnouncement this_ptr_conv;
35992         this_ptr_conv.inner = untag_ptr(this_ptr);
35993         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35995         this_ptr_conv.is_owned = false;
35996         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35997         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
35998         return ret_arr;
35999 }
36000
36001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36002         LDKUnsignedChannelAnnouncement this_ptr_conv;
36003         this_ptr_conv.inner = untag_ptr(this_ptr);
36004         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36006         this_ptr_conv.is_owned = false;
36007         LDKPublicKey val_ref;
36008         CHECK((*env)->GetArrayLength(env, val) == 33);
36009         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36010         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
36011 }
36012
36013 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
36014         LDKUnsignedChannelAnnouncement this_ptr_conv;
36015         this_ptr_conv.inner = untag_ptr(this_ptr);
36016         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36018         this_ptr_conv.is_owned = false;
36019         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36020         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
36021         return ret_arr;
36022 }
36023
36024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36025         LDKUnsignedChannelAnnouncement this_ptr_conv;
36026         this_ptr_conv.inner = untag_ptr(this_ptr);
36027         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36029         this_ptr_conv.is_owned = false;
36030         LDKPublicKey val_ref;
36031         CHECK((*env)->GetArrayLength(env, val) == 33);
36032         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36033         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
36034 }
36035
36036 static inline uint64_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
36037         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
36038         int64_t ret_ref = 0;
36039         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36040         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36041         return ret_ref;
36042 }
36043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36044         LDKUnsignedChannelAnnouncement arg_conv;
36045         arg_conv.inner = untag_ptr(arg);
36046         arg_conv.is_owned = ptr_is_owned(arg);
36047         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36048         arg_conv.is_owned = false;
36049         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
36050         return ret_conv;
36051 }
36052
36053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36054         LDKUnsignedChannelAnnouncement orig_conv;
36055         orig_conv.inner = untag_ptr(orig);
36056         orig_conv.is_owned = ptr_is_owned(orig);
36057         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36058         orig_conv.is_owned = false;
36059         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
36060         int64_t ret_ref = 0;
36061         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36062         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36063         return ret_ref;
36064 }
36065
36066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36067         LDKChannelAnnouncement this_obj_conv;
36068         this_obj_conv.inner = untag_ptr(this_obj);
36069         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36071         ChannelAnnouncement_free(this_obj_conv);
36072 }
36073
36074 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
36075         LDKChannelAnnouncement this_ptr_conv;
36076         this_ptr_conv.inner = untag_ptr(this_ptr);
36077         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36079         this_ptr_conv.is_owned = false;
36080         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36081         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
36082         return ret_arr;
36083 }
36084
36085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36086         LDKChannelAnnouncement this_ptr_conv;
36087         this_ptr_conv.inner = untag_ptr(this_ptr);
36088         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36090         this_ptr_conv.is_owned = false;
36091         LDKSignature val_ref;
36092         CHECK((*env)->GetArrayLength(env, val) == 64);
36093         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36094         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
36095 }
36096
36097 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
36098         LDKChannelAnnouncement this_ptr_conv;
36099         this_ptr_conv.inner = untag_ptr(this_ptr);
36100         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36102         this_ptr_conv.is_owned = false;
36103         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36104         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
36105         return ret_arr;
36106 }
36107
36108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36109         LDKChannelAnnouncement this_ptr_conv;
36110         this_ptr_conv.inner = untag_ptr(this_ptr);
36111         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36113         this_ptr_conv.is_owned = false;
36114         LDKSignature val_ref;
36115         CHECK((*env)->GetArrayLength(env, val) == 64);
36116         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36117         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
36118 }
36119
36120 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
36121         LDKChannelAnnouncement this_ptr_conv;
36122         this_ptr_conv.inner = untag_ptr(this_ptr);
36123         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36125         this_ptr_conv.is_owned = false;
36126         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36127         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
36128         return ret_arr;
36129 }
36130
36131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36132         LDKChannelAnnouncement this_ptr_conv;
36133         this_ptr_conv.inner = untag_ptr(this_ptr);
36134         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36136         this_ptr_conv.is_owned = false;
36137         LDKSignature val_ref;
36138         CHECK((*env)->GetArrayLength(env, val) == 64);
36139         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36140         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
36141 }
36142
36143 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
36144         LDKChannelAnnouncement this_ptr_conv;
36145         this_ptr_conv.inner = untag_ptr(this_ptr);
36146         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36148         this_ptr_conv.is_owned = false;
36149         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36150         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
36151         return ret_arr;
36152 }
36153
36154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36155         LDKChannelAnnouncement this_ptr_conv;
36156         this_ptr_conv.inner = untag_ptr(this_ptr);
36157         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36159         this_ptr_conv.is_owned = false;
36160         LDKSignature val_ref;
36161         CHECK((*env)->GetArrayLength(env, val) == 64);
36162         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36163         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
36164 }
36165
36166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
36167         LDKChannelAnnouncement this_ptr_conv;
36168         this_ptr_conv.inner = untag_ptr(this_ptr);
36169         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36171         this_ptr_conv.is_owned = false;
36172         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
36173         int64_t ret_ref = 0;
36174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36175         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36176         return ret_ref;
36177 }
36178
36179 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36180         LDKChannelAnnouncement this_ptr_conv;
36181         this_ptr_conv.inner = untag_ptr(this_ptr);
36182         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36184         this_ptr_conv.is_owned = false;
36185         LDKUnsignedChannelAnnouncement val_conv;
36186         val_conv.inner = untag_ptr(val);
36187         val_conv.is_owned = ptr_is_owned(val);
36188         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36189         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
36190         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
36191 }
36192
36193 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) {
36194         LDKSignature node_signature_1_arg_ref;
36195         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
36196         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
36197         LDKSignature node_signature_2_arg_ref;
36198         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
36199         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
36200         LDKSignature bitcoin_signature_1_arg_ref;
36201         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
36202         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
36203         LDKSignature bitcoin_signature_2_arg_ref;
36204         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
36205         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
36206         LDKUnsignedChannelAnnouncement contents_arg_conv;
36207         contents_arg_conv.inner = untag_ptr(contents_arg);
36208         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
36209         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
36210         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
36211         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);
36212         int64_t ret_ref = 0;
36213         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36214         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36215         return ret_ref;
36216 }
36217
36218 static inline uint64_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
36219         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
36220         int64_t ret_ref = 0;
36221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36222         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36223         return ret_ref;
36224 }
36225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36226         LDKChannelAnnouncement arg_conv;
36227         arg_conv.inner = untag_ptr(arg);
36228         arg_conv.is_owned = ptr_is_owned(arg);
36229         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36230         arg_conv.is_owned = false;
36231         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
36232         return ret_conv;
36233 }
36234
36235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36236         LDKChannelAnnouncement orig_conv;
36237         orig_conv.inner = untag_ptr(orig);
36238         orig_conv.is_owned = ptr_is_owned(orig);
36239         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36240         orig_conv.is_owned = false;
36241         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
36242         int64_t ret_ref = 0;
36243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36244         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36245         return ret_ref;
36246 }
36247
36248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36249         LDKUnsignedChannelUpdate this_obj_conv;
36250         this_obj_conv.inner = untag_ptr(this_obj);
36251         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36253         UnsignedChannelUpdate_free(this_obj_conv);
36254 }
36255
36256 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36257         LDKUnsignedChannelUpdate this_ptr_conv;
36258         this_ptr_conv.inner = untag_ptr(this_ptr);
36259         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36261         this_ptr_conv.is_owned = false;
36262         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36263         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
36264         return ret_arr;
36265 }
36266
36267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36268         LDKUnsignedChannelUpdate this_ptr_conv;
36269         this_ptr_conv.inner = untag_ptr(this_ptr);
36270         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36272         this_ptr_conv.is_owned = false;
36273         LDKThirtyTwoBytes val_ref;
36274         CHECK((*env)->GetArrayLength(env, val) == 32);
36275         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36276         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
36277 }
36278
36279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36280         LDKUnsignedChannelUpdate this_ptr_conv;
36281         this_ptr_conv.inner = untag_ptr(this_ptr);
36282         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36284         this_ptr_conv.is_owned = false;
36285         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
36286         return ret_conv;
36287 }
36288
36289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36290         LDKUnsignedChannelUpdate this_ptr_conv;
36291         this_ptr_conv.inner = untag_ptr(this_ptr);
36292         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36294         this_ptr_conv.is_owned = false;
36295         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
36296 }
36297
36298 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
36299         LDKUnsignedChannelUpdate this_ptr_conv;
36300         this_ptr_conv.inner = untag_ptr(this_ptr);
36301         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36303         this_ptr_conv.is_owned = false;
36304         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
36305         return ret_conv;
36306 }
36307
36308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36309         LDKUnsignedChannelUpdate this_ptr_conv;
36310         this_ptr_conv.inner = untag_ptr(this_ptr);
36311         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36313         this_ptr_conv.is_owned = false;
36314         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
36315 }
36316
36317 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
36318         LDKUnsignedChannelUpdate this_ptr_conv;
36319         this_ptr_conv.inner = untag_ptr(this_ptr);
36320         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36322         this_ptr_conv.is_owned = false;
36323         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
36324         return ret_conv;
36325 }
36326
36327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
36328         LDKUnsignedChannelUpdate this_ptr_conv;
36329         this_ptr_conv.inner = untag_ptr(this_ptr);
36330         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36332         this_ptr_conv.is_owned = false;
36333         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
36334 }
36335
36336 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
36337         LDKUnsignedChannelUpdate this_ptr_conv;
36338         this_ptr_conv.inner = untag_ptr(this_ptr);
36339         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36341         this_ptr_conv.is_owned = false;
36342         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
36343         return ret_conv;
36344 }
36345
36346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
36347         LDKUnsignedChannelUpdate this_ptr_conv;
36348         this_ptr_conv.inner = untag_ptr(this_ptr);
36349         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36351         this_ptr_conv.is_owned = false;
36352         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
36353 }
36354
36355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
36356         LDKUnsignedChannelUpdate this_ptr_conv;
36357         this_ptr_conv.inner = untag_ptr(this_ptr);
36358         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36360         this_ptr_conv.is_owned = false;
36361         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
36362         return ret_conv;
36363 }
36364
36365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36366         LDKUnsignedChannelUpdate this_ptr_conv;
36367         this_ptr_conv.inner = untag_ptr(this_ptr);
36368         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36370         this_ptr_conv.is_owned = false;
36371         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
36372 }
36373
36374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
36375         LDKUnsignedChannelUpdate this_ptr_conv;
36376         this_ptr_conv.inner = untag_ptr(this_ptr);
36377         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36379         this_ptr_conv.is_owned = false;
36380         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_maximum_msat(&this_ptr_conv);
36381         return ret_conv;
36382 }
36383
36384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36385         LDKUnsignedChannelUpdate this_ptr_conv;
36386         this_ptr_conv.inner = untag_ptr(this_ptr);
36387         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36389         this_ptr_conv.is_owned = false;
36390         UnsignedChannelUpdate_set_htlc_maximum_msat(&this_ptr_conv, val);
36391 }
36392
36393 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
36394         LDKUnsignedChannelUpdate this_ptr_conv;
36395         this_ptr_conv.inner = untag_ptr(this_ptr);
36396         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36398         this_ptr_conv.is_owned = false;
36399         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
36400         return ret_conv;
36401 }
36402
36403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36404         LDKUnsignedChannelUpdate this_ptr_conv;
36405         this_ptr_conv.inner = untag_ptr(this_ptr);
36406         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36408         this_ptr_conv.is_owned = false;
36409         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
36410 }
36411
36412 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
36413         LDKUnsignedChannelUpdate this_ptr_conv;
36414         this_ptr_conv.inner = untag_ptr(this_ptr);
36415         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36417         this_ptr_conv.is_owned = false;
36418         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
36419         return ret_conv;
36420 }
36421
36422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36423         LDKUnsignedChannelUpdate this_ptr_conv;
36424         this_ptr_conv.inner = untag_ptr(this_ptr);
36425         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36427         this_ptr_conv.is_owned = false;
36428         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
36429 }
36430
36431 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
36432         LDKUnsignedChannelUpdate this_ptr_conv;
36433         this_ptr_conv.inner = untag_ptr(this_ptr);
36434         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36436         this_ptr_conv.is_owned = false;
36437         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_get_excess_data(&this_ptr_conv);
36438         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36439         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36440         CVec_u8Z_free(ret_var);
36441         return ret_arr;
36442 }
36443
36444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36445         LDKUnsignedChannelUpdate this_ptr_conv;
36446         this_ptr_conv.inner = untag_ptr(this_ptr);
36447         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36449         this_ptr_conv.is_owned = false;
36450         LDKCVec_u8Z val_ref;
36451         val_ref.datalen = (*env)->GetArrayLength(env, val);
36452         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
36453         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
36454         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
36455 }
36456
36457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, int64_t short_channel_id_arg, int32_t timestamp_arg, int8_t flags_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg, int64_t htlc_maximum_msat_arg, int32_t fee_base_msat_arg, int32_t fee_proportional_millionths_arg, int8_tArray excess_data_arg) {
36458         LDKThirtyTwoBytes chain_hash_arg_ref;
36459         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36460         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36461         LDKCVec_u8Z excess_data_arg_ref;
36462         excess_data_arg_ref.datalen = (*env)->GetArrayLength(env, excess_data_arg);
36463         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
36464         (*env)->GetByteArrayRegion(env, excess_data_arg, 0, excess_data_arg_ref.datalen, excess_data_arg_ref.data);
36465         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_new(chain_hash_arg_ref, short_channel_id_arg, timestamp_arg, flags_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, fee_base_msat_arg, fee_proportional_millionths_arg, excess_data_arg_ref);
36466         int64_t ret_ref = 0;
36467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36468         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36469         return ret_ref;
36470 }
36471
36472 static inline uint64_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
36473         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
36474         int64_t ret_ref = 0;
36475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36476         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36477         return ret_ref;
36478 }
36479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36480         LDKUnsignedChannelUpdate arg_conv;
36481         arg_conv.inner = untag_ptr(arg);
36482         arg_conv.is_owned = ptr_is_owned(arg);
36483         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36484         arg_conv.is_owned = false;
36485         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
36486         return ret_conv;
36487 }
36488
36489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36490         LDKUnsignedChannelUpdate orig_conv;
36491         orig_conv.inner = untag_ptr(orig);
36492         orig_conv.is_owned = ptr_is_owned(orig);
36493         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36494         orig_conv.is_owned = false;
36495         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
36496         int64_t ret_ref = 0;
36497         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36498         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36499         return ret_ref;
36500 }
36501
36502 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36503         LDKChannelUpdate this_obj_conv;
36504         this_obj_conv.inner = untag_ptr(this_obj);
36505         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36507         ChannelUpdate_free(this_obj_conv);
36508 }
36509
36510 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36511         LDKChannelUpdate this_ptr_conv;
36512         this_ptr_conv.inner = untag_ptr(this_ptr);
36513         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36515         this_ptr_conv.is_owned = false;
36516         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36517         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
36518         return ret_arr;
36519 }
36520
36521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36522         LDKChannelUpdate this_ptr_conv;
36523         this_ptr_conv.inner = untag_ptr(this_ptr);
36524         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36526         this_ptr_conv.is_owned = false;
36527         LDKSignature val_ref;
36528         CHECK((*env)->GetArrayLength(env, val) == 64);
36529         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36530         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
36531 }
36532
36533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
36534         LDKChannelUpdate this_ptr_conv;
36535         this_ptr_conv.inner = untag_ptr(this_ptr);
36536         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36538         this_ptr_conv.is_owned = false;
36539         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
36540         int64_t ret_ref = 0;
36541         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36542         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36543         return ret_ref;
36544 }
36545
36546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36547         LDKChannelUpdate this_ptr_conv;
36548         this_ptr_conv.inner = untag_ptr(this_ptr);
36549         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36551         this_ptr_conv.is_owned = false;
36552         LDKUnsignedChannelUpdate val_conv;
36553         val_conv.inner = untag_ptr(val);
36554         val_conv.is_owned = ptr_is_owned(val);
36555         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36556         val_conv = UnsignedChannelUpdate_clone(&val_conv);
36557         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
36558 }
36559
36560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
36561         LDKSignature signature_arg_ref;
36562         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36563         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36564         LDKUnsignedChannelUpdate contents_arg_conv;
36565         contents_arg_conv.inner = untag_ptr(contents_arg);
36566         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
36567         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
36568         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
36569         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
36570         int64_t ret_ref = 0;
36571         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36572         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36573         return ret_ref;
36574 }
36575
36576 static inline uint64_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
36577         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
36578         int64_t ret_ref = 0;
36579         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36580         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36581         return ret_ref;
36582 }
36583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36584         LDKChannelUpdate arg_conv;
36585         arg_conv.inner = untag_ptr(arg);
36586         arg_conv.is_owned = ptr_is_owned(arg);
36587         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36588         arg_conv.is_owned = false;
36589         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
36590         return ret_conv;
36591 }
36592
36593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36594         LDKChannelUpdate orig_conv;
36595         orig_conv.inner = untag_ptr(orig);
36596         orig_conv.is_owned = ptr_is_owned(orig);
36597         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36598         orig_conv.is_owned = false;
36599         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
36600         int64_t ret_ref = 0;
36601         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36602         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36603         return ret_ref;
36604 }
36605
36606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36607         LDKQueryChannelRange this_obj_conv;
36608         this_obj_conv.inner = untag_ptr(this_obj);
36609         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36611         QueryChannelRange_free(this_obj_conv);
36612 }
36613
36614 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36615         LDKQueryChannelRange this_ptr_conv;
36616         this_ptr_conv.inner = untag_ptr(this_ptr);
36617         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36619         this_ptr_conv.is_owned = false;
36620         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36621         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
36622         return ret_arr;
36623 }
36624
36625 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36626         LDKQueryChannelRange this_ptr_conv;
36627         this_ptr_conv.inner = untag_ptr(this_ptr);
36628         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36629         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36630         this_ptr_conv.is_owned = false;
36631         LDKThirtyTwoBytes val_ref;
36632         CHECK((*env)->GetArrayLength(env, val) == 32);
36633         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36634         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
36635 }
36636
36637 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
36638         LDKQueryChannelRange this_ptr_conv;
36639         this_ptr_conv.inner = untag_ptr(this_ptr);
36640         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36642         this_ptr_conv.is_owned = false;
36643         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
36644         return ret_conv;
36645 }
36646
36647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36648         LDKQueryChannelRange this_ptr_conv;
36649         this_ptr_conv.inner = untag_ptr(this_ptr);
36650         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36652         this_ptr_conv.is_owned = false;
36653         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
36654 }
36655
36656 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
36657         LDKQueryChannelRange this_ptr_conv;
36658         this_ptr_conv.inner = untag_ptr(this_ptr);
36659         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36661         this_ptr_conv.is_owned = false;
36662         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
36663         return ret_conv;
36664 }
36665
36666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36667         LDKQueryChannelRange this_ptr_conv;
36668         this_ptr_conv.inner = untag_ptr(this_ptr);
36669         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36671         this_ptr_conv.is_owned = false;
36672         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
36673 }
36674
36675 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) {
36676         LDKThirtyTwoBytes chain_hash_arg_ref;
36677         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36678         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36679         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
36680         int64_t ret_ref = 0;
36681         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36682         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36683         return ret_ref;
36684 }
36685
36686 static inline uint64_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
36687         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
36688         int64_t ret_ref = 0;
36689         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36690         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36691         return ret_ref;
36692 }
36693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36694         LDKQueryChannelRange arg_conv;
36695         arg_conv.inner = untag_ptr(arg);
36696         arg_conv.is_owned = ptr_is_owned(arg);
36697         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36698         arg_conv.is_owned = false;
36699         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
36700         return ret_conv;
36701 }
36702
36703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36704         LDKQueryChannelRange orig_conv;
36705         orig_conv.inner = untag_ptr(orig);
36706         orig_conv.is_owned = ptr_is_owned(orig);
36707         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36708         orig_conv.is_owned = false;
36709         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
36710         int64_t ret_ref = 0;
36711         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36712         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36713         return ret_ref;
36714 }
36715
36716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36717         LDKReplyChannelRange this_obj_conv;
36718         this_obj_conv.inner = untag_ptr(this_obj);
36719         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36721         ReplyChannelRange_free(this_obj_conv);
36722 }
36723
36724 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36725         LDKReplyChannelRange this_ptr_conv;
36726         this_ptr_conv.inner = untag_ptr(this_ptr);
36727         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36729         this_ptr_conv.is_owned = false;
36730         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36731         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
36732         return ret_arr;
36733 }
36734
36735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36736         LDKReplyChannelRange this_ptr_conv;
36737         this_ptr_conv.inner = untag_ptr(this_ptr);
36738         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36740         this_ptr_conv.is_owned = false;
36741         LDKThirtyTwoBytes val_ref;
36742         CHECK((*env)->GetArrayLength(env, val) == 32);
36743         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36744         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
36745 }
36746
36747 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
36748         LDKReplyChannelRange this_ptr_conv;
36749         this_ptr_conv.inner = untag_ptr(this_ptr);
36750         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36752         this_ptr_conv.is_owned = false;
36753         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
36754         return ret_conv;
36755 }
36756
36757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36758         LDKReplyChannelRange this_ptr_conv;
36759         this_ptr_conv.inner = untag_ptr(this_ptr);
36760         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36762         this_ptr_conv.is_owned = false;
36763         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
36764 }
36765
36766 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
36767         LDKReplyChannelRange this_ptr_conv;
36768         this_ptr_conv.inner = untag_ptr(this_ptr);
36769         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36771         this_ptr_conv.is_owned = false;
36772         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
36773         return ret_conv;
36774 }
36775
36776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36777         LDKReplyChannelRange this_ptr_conv;
36778         this_ptr_conv.inner = untag_ptr(this_ptr);
36779         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36781         this_ptr_conv.is_owned = false;
36782         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
36783 }
36784
36785 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
36786         LDKReplyChannelRange this_ptr_conv;
36787         this_ptr_conv.inner = untag_ptr(this_ptr);
36788         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36790         this_ptr_conv.is_owned = false;
36791         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
36792         return ret_conv;
36793 }
36794
36795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
36796         LDKReplyChannelRange this_ptr_conv;
36797         this_ptr_conv.inner = untag_ptr(this_ptr);
36798         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36800         this_ptr_conv.is_owned = false;
36801         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
36802 }
36803
36804 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
36805         LDKReplyChannelRange this_ptr_conv;
36806         this_ptr_conv.inner = untag_ptr(this_ptr);
36807         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36809         this_ptr_conv.is_owned = false;
36810         LDKCVec_u64Z ret_var = ReplyChannelRange_get_short_channel_ids(&this_ptr_conv);
36811         int64_tArray ret_arr = NULL;
36812         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
36813         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
36814         for (size_t g = 0; g < ret_var.datalen; g++) {
36815                 int64_t ret_conv_6_conv = ret_var.data[g];
36816                 ret_arr_ptr[g] = ret_conv_6_conv;
36817         }
36818         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
36819         FREE(ret_var.data);
36820         return ret_arr;
36821 }
36822
36823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
36824         LDKReplyChannelRange this_ptr_conv;
36825         this_ptr_conv.inner = untag_ptr(this_ptr);
36826         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36828         this_ptr_conv.is_owned = false;
36829         LDKCVec_u64Z val_constr;
36830         val_constr.datalen = (*env)->GetArrayLength(env, val);
36831         if (val_constr.datalen > 0)
36832                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36833         else
36834                 val_constr.data = NULL;
36835         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36836         for (size_t g = 0; g < val_constr.datalen; g++) {
36837                 int64_t val_conv_6 = val_vals[g];
36838                 val_constr.data[g] = val_conv_6;
36839         }
36840         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36841         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
36842 }
36843
36844 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) {
36845         LDKThirtyTwoBytes chain_hash_arg_ref;
36846         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36847         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36848         LDKCVec_u64Z short_channel_ids_arg_constr;
36849         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
36850         if (short_channel_ids_arg_constr.datalen > 0)
36851                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36852         else
36853                 short_channel_ids_arg_constr.data = NULL;
36854         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
36855         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
36856                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
36857                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
36858         }
36859         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
36860         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
36861         int64_t ret_ref = 0;
36862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36863         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36864         return ret_ref;
36865 }
36866
36867 static inline uint64_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
36868         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
36869         int64_t ret_ref = 0;
36870         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36871         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36872         return ret_ref;
36873 }
36874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36875         LDKReplyChannelRange arg_conv;
36876         arg_conv.inner = untag_ptr(arg);
36877         arg_conv.is_owned = ptr_is_owned(arg);
36878         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36879         arg_conv.is_owned = false;
36880         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
36881         return ret_conv;
36882 }
36883
36884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36885         LDKReplyChannelRange orig_conv;
36886         orig_conv.inner = untag_ptr(orig);
36887         orig_conv.is_owned = ptr_is_owned(orig);
36888         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36889         orig_conv.is_owned = false;
36890         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
36891         int64_t ret_ref = 0;
36892         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36893         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36894         return ret_ref;
36895 }
36896
36897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36898         LDKQueryShortChannelIds this_obj_conv;
36899         this_obj_conv.inner = untag_ptr(this_obj);
36900         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36902         QueryShortChannelIds_free(this_obj_conv);
36903 }
36904
36905 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36906         LDKQueryShortChannelIds this_ptr_conv;
36907         this_ptr_conv.inner = untag_ptr(this_ptr);
36908         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36910         this_ptr_conv.is_owned = false;
36911         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36912         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
36913         return ret_arr;
36914 }
36915
36916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36917         LDKQueryShortChannelIds this_ptr_conv;
36918         this_ptr_conv.inner = untag_ptr(this_ptr);
36919         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36921         this_ptr_conv.is_owned = false;
36922         LDKThirtyTwoBytes val_ref;
36923         CHECK((*env)->GetArrayLength(env, val) == 32);
36924         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36925         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
36926 }
36927
36928 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
36929         LDKQueryShortChannelIds this_ptr_conv;
36930         this_ptr_conv.inner = untag_ptr(this_ptr);
36931         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36933         this_ptr_conv.is_owned = false;
36934         LDKCVec_u64Z ret_var = QueryShortChannelIds_get_short_channel_ids(&this_ptr_conv);
36935         int64_tArray ret_arr = NULL;
36936         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
36937         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
36938         for (size_t g = 0; g < ret_var.datalen; g++) {
36939                 int64_t ret_conv_6_conv = ret_var.data[g];
36940                 ret_arr_ptr[g] = ret_conv_6_conv;
36941         }
36942         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
36943         FREE(ret_var.data);
36944         return ret_arr;
36945 }
36946
36947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
36948         LDKQueryShortChannelIds this_ptr_conv;
36949         this_ptr_conv.inner = untag_ptr(this_ptr);
36950         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36952         this_ptr_conv.is_owned = false;
36953         LDKCVec_u64Z val_constr;
36954         val_constr.datalen = (*env)->GetArrayLength(env, val);
36955         if (val_constr.datalen > 0)
36956                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36957         else
36958                 val_constr.data = NULL;
36959         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36960         for (size_t g = 0; g < val_constr.datalen; g++) {
36961                 int64_t val_conv_6 = val_vals[g];
36962                 val_constr.data[g] = val_conv_6;
36963         }
36964         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
36965         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
36966 }
36967
36968 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) {
36969         LDKThirtyTwoBytes chain_hash_arg_ref;
36970         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
36971         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
36972         LDKCVec_u64Z short_channel_ids_arg_constr;
36973         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
36974         if (short_channel_ids_arg_constr.datalen > 0)
36975                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
36976         else
36977                 short_channel_ids_arg_constr.data = NULL;
36978         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
36979         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
36980                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
36981                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
36982         }
36983         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
36984         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
36985         int64_t ret_ref = 0;
36986         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36987         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36988         return ret_ref;
36989 }
36990
36991 static inline uint64_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
36992         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
36993         int64_t ret_ref = 0;
36994         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36995         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36996         return ret_ref;
36997 }
36998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36999         LDKQueryShortChannelIds arg_conv;
37000         arg_conv.inner = untag_ptr(arg);
37001         arg_conv.is_owned = ptr_is_owned(arg);
37002         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37003         arg_conv.is_owned = false;
37004         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
37005         return ret_conv;
37006 }
37007
37008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37009         LDKQueryShortChannelIds orig_conv;
37010         orig_conv.inner = untag_ptr(orig);
37011         orig_conv.is_owned = ptr_is_owned(orig);
37012         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37013         orig_conv.is_owned = false;
37014         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
37015         int64_t ret_ref = 0;
37016         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37017         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37018         return ret_ref;
37019 }
37020
37021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37022         LDKReplyShortChannelIdsEnd this_obj_conv;
37023         this_obj_conv.inner = untag_ptr(this_obj);
37024         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37026         ReplyShortChannelIdsEnd_free(this_obj_conv);
37027 }
37028
37029 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
37030         LDKReplyShortChannelIdsEnd this_ptr_conv;
37031         this_ptr_conv.inner = untag_ptr(this_ptr);
37032         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37034         this_ptr_conv.is_owned = false;
37035         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37036         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
37037         return ret_arr;
37038 }
37039
37040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37041         LDKReplyShortChannelIdsEnd this_ptr_conv;
37042         this_ptr_conv.inner = untag_ptr(this_ptr);
37043         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37045         this_ptr_conv.is_owned = false;
37046         LDKThirtyTwoBytes val_ref;
37047         CHECK((*env)->GetArrayLength(env, val) == 32);
37048         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37049         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
37050 }
37051
37052 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
37053         LDKReplyShortChannelIdsEnd this_ptr_conv;
37054         this_ptr_conv.inner = untag_ptr(this_ptr);
37055         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37057         this_ptr_conv.is_owned = false;
37058         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
37059         return ret_conv;
37060 }
37061
37062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
37063         LDKReplyShortChannelIdsEnd this_ptr_conv;
37064         this_ptr_conv.inner = untag_ptr(this_ptr);
37065         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37067         this_ptr_conv.is_owned = false;
37068         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
37069 }
37070
37071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
37072         LDKThirtyTwoBytes chain_hash_arg_ref;
37073         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
37074         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
37075         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
37076         int64_t ret_ref = 0;
37077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37078         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37079         return ret_ref;
37080 }
37081
37082 static inline uint64_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
37083         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
37084         int64_t ret_ref = 0;
37085         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37086         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37087         return ret_ref;
37088 }
37089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37090         LDKReplyShortChannelIdsEnd arg_conv;
37091         arg_conv.inner = untag_ptr(arg);
37092         arg_conv.is_owned = ptr_is_owned(arg);
37093         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37094         arg_conv.is_owned = false;
37095         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
37096         return ret_conv;
37097 }
37098
37099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37100         LDKReplyShortChannelIdsEnd orig_conv;
37101         orig_conv.inner = untag_ptr(orig);
37102         orig_conv.is_owned = ptr_is_owned(orig);
37103         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37104         orig_conv.is_owned = false;
37105         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
37106         int64_t ret_ref = 0;
37107         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37108         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37109         return ret_ref;
37110 }
37111
37112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37113         LDKGossipTimestampFilter this_obj_conv;
37114         this_obj_conv.inner = untag_ptr(this_obj);
37115         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37117         GossipTimestampFilter_free(this_obj_conv);
37118 }
37119
37120 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
37121         LDKGossipTimestampFilter this_ptr_conv;
37122         this_ptr_conv.inner = untag_ptr(this_ptr);
37123         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37125         this_ptr_conv.is_owned = false;
37126         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37127         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
37128         return ret_arr;
37129 }
37130
37131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37132         LDKGossipTimestampFilter this_ptr_conv;
37133         this_ptr_conv.inner = untag_ptr(this_ptr);
37134         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37136         this_ptr_conv.is_owned = false;
37137         LDKThirtyTwoBytes val_ref;
37138         CHECK((*env)->GetArrayLength(env, val) == 32);
37139         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37140         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
37141 }
37142
37143 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
37144         LDKGossipTimestampFilter this_ptr_conv;
37145         this_ptr_conv.inner = untag_ptr(this_ptr);
37146         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37148         this_ptr_conv.is_owned = false;
37149         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
37150         return ret_conv;
37151 }
37152
37153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37154         LDKGossipTimestampFilter this_ptr_conv;
37155         this_ptr_conv.inner = untag_ptr(this_ptr);
37156         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37158         this_ptr_conv.is_owned = false;
37159         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
37160 }
37161
37162 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
37163         LDKGossipTimestampFilter this_ptr_conv;
37164         this_ptr_conv.inner = untag_ptr(this_ptr);
37165         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37167         this_ptr_conv.is_owned = false;
37168         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
37169         return ret_conv;
37170 }
37171
37172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37173         LDKGossipTimestampFilter this_ptr_conv;
37174         this_ptr_conv.inner = untag_ptr(this_ptr);
37175         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37177         this_ptr_conv.is_owned = false;
37178         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
37179 }
37180
37181 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) {
37182         LDKThirtyTwoBytes chain_hash_arg_ref;
37183         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
37184         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
37185         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
37186         int64_t ret_ref = 0;
37187         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37188         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37189         return ret_ref;
37190 }
37191
37192 static inline uint64_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
37193         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
37194         int64_t ret_ref = 0;
37195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37196         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37197         return ret_ref;
37198 }
37199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37200         LDKGossipTimestampFilter arg_conv;
37201         arg_conv.inner = untag_ptr(arg);
37202         arg_conv.is_owned = ptr_is_owned(arg);
37203         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37204         arg_conv.is_owned = false;
37205         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
37206         return ret_conv;
37207 }
37208
37209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37210         LDKGossipTimestampFilter orig_conv;
37211         orig_conv.inner = untag_ptr(orig);
37212         orig_conv.is_owned = ptr_is_owned(orig);
37213         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37214         orig_conv.is_owned = false;
37215         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
37216         int64_t ret_ref = 0;
37217         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37218         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37219         return ret_ref;
37220 }
37221
37222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37223         if (!ptr_is_owned(this_ptr)) return;
37224         void* this_ptr_ptr = untag_ptr(this_ptr);
37225         CHECK_ACCESS(this_ptr_ptr);
37226         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
37227         FREE(untag_ptr(this_ptr));
37228         ErrorAction_free(this_ptr_conv);
37229 }
37230
37231 static inline uint64_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
37232         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
37233         *ret_copy = ErrorAction_clone(arg);
37234         int64_t ret_ref = tag_ptr(ret_copy, true);
37235         return ret_ref;
37236 }
37237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37238         LDKErrorAction* arg_conv = (LDKErrorAction*)untag_ptr(arg);
37239         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
37240         return ret_conv;
37241 }
37242
37243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37244         LDKErrorAction* orig_conv = (LDKErrorAction*)untag_ptr(orig);
37245         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
37246         *ret_copy = ErrorAction_clone(orig_conv);
37247         int64_t ret_ref = tag_ptr(ret_copy, true);
37248         return ret_ref;
37249 }
37250
37251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
37252         LDKErrorMessage msg_conv;
37253         msg_conv.inner = untag_ptr(msg);
37254         msg_conv.is_owned = ptr_is_owned(msg);
37255         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37256         msg_conv = ErrorMessage_clone(&msg_conv);
37257         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
37258         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
37259         int64_t ret_ref = tag_ptr(ret_copy, true);
37260         return ret_ref;
37261 }
37262
37263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
37264         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
37265         *ret_copy = ErrorAction_ignore_error();
37266         int64_t ret_ref = tag_ptr(ret_copy, true);
37267         return ret_ref;
37268 }
37269
37270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
37271         LDKLevel a_conv = LDKLevel_from_java(env, a);
37272         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
37273         *ret_copy = ErrorAction_ignore_and_log(a_conv);
37274         int64_t ret_ref = tag_ptr(ret_copy, true);
37275         return ret_ref;
37276 }
37277
37278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
37279         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
37280         *ret_copy = ErrorAction_ignore_duplicate_gossip();
37281         int64_t ret_ref = tag_ptr(ret_copy, true);
37282         return ret_ref;
37283 }
37284
37285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
37286         LDKErrorMessage msg_conv;
37287         msg_conv.inner = untag_ptr(msg);
37288         msg_conv.is_owned = ptr_is_owned(msg);
37289         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37290         msg_conv = ErrorMessage_clone(&msg_conv);
37291         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
37292         *ret_copy = ErrorAction_send_error_message(msg_conv);
37293         int64_t ret_ref = tag_ptr(ret_copy, true);
37294         return ret_ref;
37295 }
37296
37297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
37298         LDKWarningMessage msg_conv;
37299         msg_conv.inner = untag_ptr(msg);
37300         msg_conv.is_owned = ptr_is_owned(msg);
37301         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
37302         msg_conv = WarningMessage_clone(&msg_conv);
37303         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
37304         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
37305         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
37306         int64_t ret_ref = tag_ptr(ret_copy, true);
37307         return ret_ref;
37308 }
37309
37310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37311         LDKLightningError this_obj_conv;
37312         this_obj_conv.inner = untag_ptr(this_obj);
37313         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37315         LightningError_free(this_obj_conv);
37316 }
37317
37318 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
37319         LDKLightningError this_ptr_conv;
37320         this_ptr_conv.inner = untag_ptr(this_ptr);
37321         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37323         this_ptr_conv.is_owned = false;
37324         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
37325         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
37326         Str_free(ret_str);
37327         return ret_conv;
37328 }
37329
37330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
37331         LDKLightningError this_ptr_conv;
37332         this_ptr_conv.inner = untag_ptr(this_ptr);
37333         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37335         this_ptr_conv.is_owned = false;
37336         LDKStr val_conv = java_to_owned_str(env, val);
37337         LightningError_set_err(&this_ptr_conv, val_conv);
37338 }
37339
37340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
37341         LDKLightningError this_ptr_conv;
37342         this_ptr_conv.inner = untag_ptr(this_ptr);
37343         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37345         this_ptr_conv.is_owned = false;
37346         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
37347         *ret_copy = LightningError_get_action(&this_ptr_conv);
37348         int64_t ret_ref = tag_ptr(ret_copy, true);
37349         return ret_ref;
37350 }
37351
37352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37353         LDKLightningError this_ptr_conv;
37354         this_ptr_conv.inner = untag_ptr(this_ptr);
37355         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37357         this_ptr_conv.is_owned = false;
37358         void* val_ptr = untag_ptr(val);
37359         CHECK_ACCESS(val_ptr);
37360         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
37361         val_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(val));
37362         LightningError_set_action(&this_ptr_conv, val_conv);
37363 }
37364
37365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
37366         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
37367         void* action_arg_ptr = untag_ptr(action_arg);
37368         CHECK_ACCESS(action_arg_ptr);
37369         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
37370         action_arg_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action_arg));
37371         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
37372         int64_t ret_ref = 0;
37373         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37374         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37375         return ret_ref;
37376 }
37377
37378 static inline uint64_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
37379         LDKLightningError ret_var = LightningError_clone(arg);
37380         int64_t ret_ref = 0;
37381         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37382         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37383         return ret_ref;
37384 }
37385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37386         LDKLightningError arg_conv;
37387         arg_conv.inner = untag_ptr(arg);
37388         arg_conv.is_owned = ptr_is_owned(arg);
37389         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37390         arg_conv.is_owned = false;
37391         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
37392         return ret_conv;
37393 }
37394
37395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37396         LDKLightningError orig_conv;
37397         orig_conv.inner = untag_ptr(orig);
37398         orig_conv.is_owned = ptr_is_owned(orig);
37399         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37400         orig_conv.is_owned = false;
37401         LDKLightningError ret_var = LightningError_clone(&orig_conv);
37402         int64_t ret_ref = 0;
37403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37404         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37405         return ret_ref;
37406 }
37407
37408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37409         LDKCommitmentUpdate this_obj_conv;
37410         this_obj_conv.inner = untag_ptr(this_obj);
37411         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37413         CommitmentUpdate_free(this_obj_conv);
37414 }
37415
37416 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
37417         LDKCommitmentUpdate this_ptr_conv;
37418         this_ptr_conv.inner = untag_ptr(this_ptr);
37419         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37421         this_ptr_conv.is_owned = false;
37422         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
37423         int64_tArray ret_arr = NULL;
37424         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37425         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37426         for (size_t p = 0; p < ret_var.datalen; p++) {
37427                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
37428                 int64_t ret_conv_15_ref = 0;
37429                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
37430                 ret_conv_15_ref = tag_ptr(ret_conv_15_var.inner, ret_conv_15_var.is_owned);
37431                 ret_arr_ptr[p] = ret_conv_15_ref;
37432         }
37433         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37434         FREE(ret_var.data);
37435         return ret_arr;
37436 }
37437
37438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37439         LDKCommitmentUpdate this_ptr_conv;
37440         this_ptr_conv.inner = untag_ptr(this_ptr);
37441         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37443         this_ptr_conv.is_owned = false;
37444         LDKCVec_UpdateAddHTLCZ val_constr;
37445         val_constr.datalen = (*env)->GetArrayLength(env, val);
37446         if (val_constr.datalen > 0)
37447                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
37448         else
37449                 val_constr.data = NULL;
37450         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37451         for (size_t p = 0; p < val_constr.datalen; p++) {
37452                 int64_t val_conv_15 = val_vals[p];
37453                 LDKUpdateAddHTLC val_conv_15_conv;
37454                 val_conv_15_conv.inner = untag_ptr(val_conv_15);
37455                 val_conv_15_conv.is_owned = ptr_is_owned(val_conv_15);
37456                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
37457                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
37458                 val_constr.data[p] = val_conv_15_conv;
37459         }
37460         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37461         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
37462 }
37463
37464 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
37465         LDKCommitmentUpdate this_ptr_conv;
37466         this_ptr_conv.inner = untag_ptr(this_ptr);
37467         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37469         this_ptr_conv.is_owned = false;
37470         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
37471         int64_tArray ret_arr = NULL;
37472         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37473         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37474         for (size_t t = 0; t < ret_var.datalen; t++) {
37475                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
37476                 int64_t ret_conv_19_ref = 0;
37477                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
37478                 ret_conv_19_ref = tag_ptr(ret_conv_19_var.inner, ret_conv_19_var.is_owned);
37479                 ret_arr_ptr[t] = ret_conv_19_ref;
37480         }
37481         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37482         FREE(ret_var.data);
37483         return ret_arr;
37484 }
37485
37486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37487         LDKCommitmentUpdate this_ptr_conv;
37488         this_ptr_conv.inner = untag_ptr(this_ptr);
37489         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37491         this_ptr_conv.is_owned = false;
37492         LDKCVec_UpdateFulfillHTLCZ val_constr;
37493         val_constr.datalen = (*env)->GetArrayLength(env, val);
37494         if (val_constr.datalen > 0)
37495                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
37496         else
37497                 val_constr.data = NULL;
37498         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37499         for (size_t t = 0; t < val_constr.datalen; t++) {
37500                 int64_t val_conv_19 = val_vals[t];
37501                 LDKUpdateFulfillHTLC val_conv_19_conv;
37502                 val_conv_19_conv.inner = untag_ptr(val_conv_19);
37503                 val_conv_19_conv.is_owned = ptr_is_owned(val_conv_19);
37504                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
37505                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
37506                 val_constr.data[t] = val_conv_19_conv;
37507         }
37508         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37509         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
37510 }
37511
37512 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
37513         LDKCommitmentUpdate this_ptr_conv;
37514         this_ptr_conv.inner = untag_ptr(this_ptr);
37515         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37517         this_ptr_conv.is_owned = false;
37518         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
37519         int64_tArray ret_arr = NULL;
37520         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37521         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37522         for (size_t q = 0; q < ret_var.datalen; q++) {
37523                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
37524                 int64_t ret_conv_16_ref = 0;
37525                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
37526                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
37527                 ret_arr_ptr[q] = ret_conv_16_ref;
37528         }
37529         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37530         FREE(ret_var.data);
37531         return ret_arr;
37532 }
37533
37534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37535         LDKCommitmentUpdate this_ptr_conv;
37536         this_ptr_conv.inner = untag_ptr(this_ptr);
37537         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37539         this_ptr_conv.is_owned = false;
37540         LDKCVec_UpdateFailHTLCZ val_constr;
37541         val_constr.datalen = (*env)->GetArrayLength(env, val);
37542         if (val_constr.datalen > 0)
37543                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
37544         else
37545                 val_constr.data = NULL;
37546         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37547         for (size_t q = 0; q < val_constr.datalen; q++) {
37548                 int64_t val_conv_16 = val_vals[q];
37549                 LDKUpdateFailHTLC val_conv_16_conv;
37550                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
37551                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
37552                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
37553                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
37554                 val_constr.data[q] = val_conv_16_conv;
37555         }
37556         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37557         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
37558 }
37559
37560 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
37561         LDKCommitmentUpdate this_ptr_conv;
37562         this_ptr_conv.inner = untag_ptr(this_ptr);
37563         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37565         this_ptr_conv.is_owned = false;
37566         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
37567         int64_tArray ret_arr = NULL;
37568         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37569         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37570         for (size_t z = 0; z < ret_var.datalen; z++) {
37571                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
37572                 int64_t ret_conv_25_ref = 0;
37573                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
37574                 ret_conv_25_ref = tag_ptr(ret_conv_25_var.inner, ret_conv_25_var.is_owned);
37575                 ret_arr_ptr[z] = ret_conv_25_ref;
37576         }
37577         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37578         FREE(ret_var.data);
37579         return ret_arr;
37580 }
37581
37582 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) {
37583         LDKCommitmentUpdate this_ptr_conv;
37584         this_ptr_conv.inner = untag_ptr(this_ptr);
37585         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37587         this_ptr_conv.is_owned = false;
37588         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
37589         val_constr.datalen = (*env)->GetArrayLength(env, val);
37590         if (val_constr.datalen > 0)
37591                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
37592         else
37593                 val_constr.data = NULL;
37594         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37595         for (size_t z = 0; z < val_constr.datalen; z++) {
37596                 int64_t val_conv_25 = val_vals[z];
37597                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
37598                 val_conv_25_conv.inner = untag_ptr(val_conv_25);
37599                 val_conv_25_conv.is_owned = ptr_is_owned(val_conv_25);
37600                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
37601                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
37602                 val_constr.data[z] = val_conv_25_conv;
37603         }
37604         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37605         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
37606 }
37607
37608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
37609         LDKCommitmentUpdate this_ptr_conv;
37610         this_ptr_conv.inner = untag_ptr(this_ptr);
37611         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37613         this_ptr_conv.is_owned = false;
37614         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
37615         int64_t ret_ref = 0;
37616         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37617         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37618         return ret_ref;
37619 }
37620
37621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37622         LDKCommitmentUpdate this_ptr_conv;
37623         this_ptr_conv.inner = untag_ptr(this_ptr);
37624         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37626         this_ptr_conv.is_owned = false;
37627         LDKUpdateFee val_conv;
37628         val_conv.inner = untag_ptr(val);
37629         val_conv.is_owned = ptr_is_owned(val);
37630         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37631         val_conv = UpdateFee_clone(&val_conv);
37632         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
37633 }
37634
37635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
37636         LDKCommitmentUpdate this_ptr_conv;
37637         this_ptr_conv.inner = untag_ptr(this_ptr);
37638         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37639         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37640         this_ptr_conv.is_owned = false;
37641         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
37642         int64_t ret_ref = 0;
37643         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37644         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37645         return ret_ref;
37646 }
37647
37648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37649         LDKCommitmentUpdate this_ptr_conv;
37650         this_ptr_conv.inner = untag_ptr(this_ptr);
37651         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37653         this_ptr_conv.is_owned = false;
37654         LDKCommitmentSigned val_conv;
37655         val_conv.inner = untag_ptr(val);
37656         val_conv.is_owned = ptr_is_owned(val);
37657         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37658         val_conv = CommitmentSigned_clone(&val_conv);
37659         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
37660 }
37661
37662 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) {
37663         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
37664         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
37665         if (update_add_htlcs_arg_constr.datalen > 0)
37666                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
37667         else
37668                 update_add_htlcs_arg_constr.data = NULL;
37669         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
37670         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
37671                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
37672                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
37673                 update_add_htlcs_arg_conv_15_conv.inner = untag_ptr(update_add_htlcs_arg_conv_15);
37674                 update_add_htlcs_arg_conv_15_conv.is_owned = ptr_is_owned(update_add_htlcs_arg_conv_15);
37675                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
37676                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
37677                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
37678         }
37679         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
37680         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
37681         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
37682         if (update_fulfill_htlcs_arg_constr.datalen > 0)
37683                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
37684         else
37685                 update_fulfill_htlcs_arg_constr.data = NULL;
37686         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
37687         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
37688                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
37689                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
37690                 update_fulfill_htlcs_arg_conv_19_conv.inner = untag_ptr(update_fulfill_htlcs_arg_conv_19);
37691                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = ptr_is_owned(update_fulfill_htlcs_arg_conv_19);
37692                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
37693                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
37694                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
37695         }
37696         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
37697         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
37698         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
37699         if (update_fail_htlcs_arg_constr.datalen > 0)
37700                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
37701         else
37702                 update_fail_htlcs_arg_constr.data = NULL;
37703         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
37704         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
37705                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
37706                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
37707                 update_fail_htlcs_arg_conv_16_conv.inner = untag_ptr(update_fail_htlcs_arg_conv_16);
37708                 update_fail_htlcs_arg_conv_16_conv.is_owned = ptr_is_owned(update_fail_htlcs_arg_conv_16);
37709                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
37710                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
37711                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
37712         }
37713         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
37714         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
37715         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
37716         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
37717                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
37718         else
37719                 update_fail_malformed_htlcs_arg_constr.data = NULL;
37720         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
37721         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
37722                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
37723                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
37724                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = untag_ptr(update_fail_malformed_htlcs_arg_conv_25);
37725                 update_fail_malformed_htlcs_arg_conv_25_conv.is_owned = ptr_is_owned(update_fail_malformed_htlcs_arg_conv_25);
37726                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
37727                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
37728                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
37729         }
37730         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
37731         LDKUpdateFee update_fee_arg_conv;
37732         update_fee_arg_conv.inner = untag_ptr(update_fee_arg);
37733         update_fee_arg_conv.is_owned = ptr_is_owned(update_fee_arg);
37734         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
37735         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
37736         LDKCommitmentSigned commitment_signed_arg_conv;
37737         commitment_signed_arg_conv.inner = untag_ptr(commitment_signed_arg);
37738         commitment_signed_arg_conv.is_owned = ptr_is_owned(commitment_signed_arg);
37739         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
37740         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
37741         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);
37742         int64_t ret_ref = 0;
37743         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37744         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37745         return ret_ref;
37746 }
37747
37748 static inline uint64_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
37749         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
37750         int64_t ret_ref = 0;
37751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37752         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37753         return ret_ref;
37754 }
37755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37756         LDKCommitmentUpdate arg_conv;
37757         arg_conv.inner = untag_ptr(arg);
37758         arg_conv.is_owned = ptr_is_owned(arg);
37759         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37760         arg_conv.is_owned = false;
37761         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
37762         return ret_conv;
37763 }
37764
37765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37766         LDKCommitmentUpdate orig_conv;
37767         orig_conv.inner = untag_ptr(orig);
37768         orig_conv.is_owned = ptr_is_owned(orig);
37769         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37770         orig_conv.is_owned = false;
37771         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
37772         int64_t ret_ref = 0;
37773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37774         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37775         return ret_ref;
37776 }
37777
37778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37779         if (!ptr_is_owned(this_ptr)) return;
37780         void* this_ptr_ptr = untag_ptr(this_ptr);
37781         CHECK_ACCESS(this_ptr_ptr);
37782         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
37783         FREE(untag_ptr(this_ptr));
37784         ChannelMessageHandler_free(this_ptr_conv);
37785 }
37786
37787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37788         if (!ptr_is_owned(this_ptr)) return;
37789         void* this_ptr_ptr = untag_ptr(this_ptr);
37790         CHECK_ACCESS(this_ptr_ptr);
37791         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
37792         FREE(untag_ptr(this_ptr));
37793         RoutingMessageHandler_free(this_ptr_conv);
37794 }
37795
37796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37797         if (!ptr_is_owned(this_ptr)) return;
37798         void* this_ptr_ptr = untag_ptr(this_ptr);
37799         CHECK_ACCESS(this_ptr_ptr);
37800         LDKOnionMessageHandler this_ptr_conv = *(LDKOnionMessageHandler*)(this_ptr_ptr);
37801         FREE(untag_ptr(this_ptr));
37802         OnionMessageHandler_free(this_ptr_conv);
37803 }
37804
37805 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
37806         LDKAcceptChannel obj_conv;
37807         obj_conv.inner = untag_ptr(obj);
37808         obj_conv.is_owned = ptr_is_owned(obj);
37809         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37810         obj_conv.is_owned = false;
37811         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
37812         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37813         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37814         CVec_u8Z_free(ret_var);
37815         return ret_arr;
37816 }
37817
37818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37819         LDKu8slice ser_ref;
37820         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37821         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37822         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
37823         *ret_conv = AcceptChannel_read(ser_ref);
37824         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37825         return tag_ptr(ret_conv, true);
37826 }
37827
37828 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
37829         LDKAnnouncementSignatures obj_conv;
37830         obj_conv.inner = untag_ptr(obj);
37831         obj_conv.is_owned = ptr_is_owned(obj);
37832         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37833         obj_conv.is_owned = false;
37834         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
37835         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37836         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37837         CVec_u8Z_free(ret_var);
37838         return ret_arr;
37839 }
37840
37841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37842         LDKu8slice ser_ref;
37843         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37844         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37845         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
37846         *ret_conv = AnnouncementSignatures_read(ser_ref);
37847         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37848         return tag_ptr(ret_conv, true);
37849 }
37850
37851 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
37852         LDKChannelReestablish obj_conv;
37853         obj_conv.inner = untag_ptr(obj);
37854         obj_conv.is_owned = ptr_is_owned(obj);
37855         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37856         obj_conv.is_owned = false;
37857         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
37858         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37859         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37860         CVec_u8Z_free(ret_var);
37861         return ret_arr;
37862 }
37863
37864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37865         LDKu8slice ser_ref;
37866         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37867         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37868         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
37869         *ret_conv = ChannelReestablish_read(ser_ref);
37870         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37871         return tag_ptr(ret_conv, true);
37872 }
37873
37874 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
37875         LDKClosingSigned obj_conv;
37876         obj_conv.inner = untag_ptr(obj);
37877         obj_conv.is_owned = ptr_is_owned(obj);
37878         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37879         obj_conv.is_owned = false;
37880         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
37881         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37882         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37883         CVec_u8Z_free(ret_var);
37884         return ret_arr;
37885 }
37886
37887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37888         LDKu8slice ser_ref;
37889         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37890         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37891         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
37892         *ret_conv = ClosingSigned_read(ser_ref);
37893         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37894         return tag_ptr(ret_conv, true);
37895 }
37896
37897 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
37898         LDKClosingSignedFeeRange obj_conv;
37899         obj_conv.inner = untag_ptr(obj);
37900         obj_conv.is_owned = ptr_is_owned(obj);
37901         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37902         obj_conv.is_owned = false;
37903         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
37904         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37905         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37906         CVec_u8Z_free(ret_var);
37907         return ret_arr;
37908 }
37909
37910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37911         LDKu8slice ser_ref;
37912         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37913         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37914         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
37915         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
37916         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37917         return tag_ptr(ret_conv, true);
37918 }
37919
37920 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
37921         LDKCommitmentSigned obj_conv;
37922         obj_conv.inner = untag_ptr(obj);
37923         obj_conv.is_owned = ptr_is_owned(obj);
37924         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37925         obj_conv.is_owned = false;
37926         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
37927         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37928         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37929         CVec_u8Z_free(ret_var);
37930         return ret_arr;
37931 }
37932
37933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37934         LDKu8slice ser_ref;
37935         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37936         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37937         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
37938         *ret_conv = CommitmentSigned_read(ser_ref);
37939         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37940         return tag_ptr(ret_conv, true);
37941 }
37942
37943 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
37944         LDKFundingCreated obj_conv;
37945         obj_conv.inner = untag_ptr(obj);
37946         obj_conv.is_owned = ptr_is_owned(obj);
37947         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37948         obj_conv.is_owned = false;
37949         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
37950         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37951         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37952         CVec_u8Z_free(ret_var);
37953         return ret_arr;
37954 }
37955
37956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37957         LDKu8slice ser_ref;
37958         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37959         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37960         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
37961         *ret_conv = FundingCreated_read(ser_ref);
37962         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37963         return tag_ptr(ret_conv, true);
37964 }
37965
37966 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
37967         LDKFundingSigned obj_conv;
37968         obj_conv.inner = untag_ptr(obj);
37969         obj_conv.is_owned = ptr_is_owned(obj);
37970         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37971         obj_conv.is_owned = false;
37972         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
37973         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37974         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37975         CVec_u8Z_free(ret_var);
37976         return ret_arr;
37977 }
37978
37979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37980         LDKu8slice ser_ref;
37981         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37982         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37983         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
37984         *ret_conv = FundingSigned_read(ser_ref);
37985         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37986         return tag_ptr(ret_conv, true);
37987 }
37988
37989 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1write(JNIEnv *env, jclass clz, int64_t obj) {
37990         LDKChannelReady obj_conv;
37991         obj_conv.inner = untag_ptr(obj);
37992         obj_conv.is_owned = ptr_is_owned(obj);
37993         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37994         obj_conv.is_owned = false;
37995         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
37996         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37997         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37998         CVec_u8Z_free(ret_var);
37999         return ret_arr;
38000 }
38001
38002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38003         LDKu8slice ser_ref;
38004         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38005         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38006         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
38007         *ret_conv = ChannelReady_read(ser_ref);
38008         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38009         return tag_ptr(ret_conv, true);
38010 }
38011
38012 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
38013         LDKInit obj_conv;
38014         obj_conv.inner = untag_ptr(obj);
38015         obj_conv.is_owned = ptr_is_owned(obj);
38016         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38017         obj_conv.is_owned = false;
38018         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
38019         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38020         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38021         CVec_u8Z_free(ret_var);
38022         return ret_arr;
38023 }
38024
38025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38026         LDKu8slice ser_ref;
38027         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38028         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38029         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
38030         *ret_conv = Init_read(ser_ref);
38031         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38032         return tag_ptr(ret_conv, true);
38033 }
38034
38035 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
38036         LDKOpenChannel obj_conv;
38037         obj_conv.inner = untag_ptr(obj);
38038         obj_conv.is_owned = ptr_is_owned(obj);
38039         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38040         obj_conv.is_owned = false;
38041         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
38042         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38043         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38044         CVec_u8Z_free(ret_var);
38045         return ret_arr;
38046 }
38047
38048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38049         LDKu8slice ser_ref;
38050         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38051         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38052         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
38053         *ret_conv = OpenChannel_read(ser_ref);
38054         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38055         return tag_ptr(ret_conv, true);
38056 }
38057
38058 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
38059         LDKRevokeAndACK obj_conv;
38060         obj_conv.inner = untag_ptr(obj);
38061         obj_conv.is_owned = ptr_is_owned(obj);
38062         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38063         obj_conv.is_owned = false;
38064         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
38065         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38066         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38067         CVec_u8Z_free(ret_var);
38068         return ret_arr;
38069 }
38070
38071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38072         LDKu8slice ser_ref;
38073         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38074         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38075         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
38076         *ret_conv = RevokeAndACK_read(ser_ref);
38077         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38078         return tag_ptr(ret_conv, true);
38079 }
38080
38081 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
38082         LDKShutdown obj_conv;
38083         obj_conv.inner = untag_ptr(obj);
38084         obj_conv.is_owned = ptr_is_owned(obj);
38085         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38086         obj_conv.is_owned = false;
38087         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
38088         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38089         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38090         CVec_u8Z_free(ret_var);
38091         return ret_arr;
38092 }
38093
38094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38095         LDKu8slice ser_ref;
38096         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38097         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38098         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
38099         *ret_conv = Shutdown_read(ser_ref);
38100         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38101         return tag_ptr(ret_conv, true);
38102 }
38103
38104 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
38105         LDKUpdateFailHTLC obj_conv;
38106         obj_conv.inner = untag_ptr(obj);
38107         obj_conv.is_owned = ptr_is_owned(obj);
38108         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38109         obj_conv.is_owned = false;
38110         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
38111         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38112         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38113         CVec_u8Z_free(ret_var);
38114         return ret_arr;
38115 }
38116
38117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38118         LDKu8slice ser_ref;
38119         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38120         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38121         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
38122         *ret_conv = UpdateFailHTLC_read(ser_ref);
38123         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38124         return tag_ptr(ret_conv, true);
38125 }
38126
38127 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
38128         LDKUpdateFailMalformedHTLC obj_conv;
38129         obj_conv.inner = untag_ptr(obj);
38130         obj_conv.is_owned = ptr_is_owned(obj);
38131         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38132         obj_conv.is_owned = false;
38133         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
38134         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38135         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38136         CVec_u8Z_free(ret_var);
38137         return ret_arr;
38138 }
38139
38140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38141         LDKu8slice ser_ref;
38142         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38143         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38144         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
38145         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
38146         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38147         return tag_ptr(ret_conv, true);
38148 }
38149
38150 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
38151         LDKUpdateFee obj_conv;
38152         obj_conv.inner = untag_ptr(obj);
38153         obj_conv.is_owned = ptr_is_owned(obj);
38154         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38155         obj_conv.is_owned = false;
38156         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
38157         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38158         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38159         CVec_u8Z_free(ret_var);
38160         return ret_arr;
38161 }
38162
38163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38164         LDKu8slice ser_ref;
38165         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38166         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38167         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
38168         *ret_conv = UpdateFee_read(ser_ref);
38169         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38170         return tag_ptr(ret_conv, true);
38171 }
38172
38173 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
38174         LDKUpdateFulfillHTLC obj_conv;
38175         obj_conv.inner = untag_ptr(obj);
38176         obj_conv.is_owned = ptr_is_owned(obj);
38177         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38178         obj_conv.is_owned = false;
38179         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
38180         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38181         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38182         CVec_u8Z_free(ret_var);
38183         return ret_arr;
38184 }
38185
38186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38187         LDKu8slice ser_ref;
38188         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38189         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38190         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
38191         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
38192         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38193         return tag_ptr(ret_conv, true);
38194 }
38195
38196 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
38197         LDKUpdateAddHTLC obj_conv;
38198         obj_conv.inner = untag_ptr(obj);
38199         obj_conv.is_owned = ptr_is_owned(obj);
38200         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38201         obj_conv.is_owned = false;
38202         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
38203         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38204         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38205         CVec_u8Z_free(ret_var);
38206         return ret_arr;
38207 }
38208
38209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38210         LDKu8slice ser_ref;
38211         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38212         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38213         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
38214         *ret_conv = UpdateAddHTLC_read(ser_ref);
38215         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38216         return tag_ptr(ret_conv, true);
38217 }
38218
38219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38220         LDKu8slice ser_ref;
38221         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38222         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38223         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
38224         *ret_conv = OnionMessage_read(ser_ref);
38225         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38226         return tag_ptr(ret_conv, true);
38227 }
38228
38229 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OnionMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
38230         LDKOnionMessage obj_conv;
38231         obj_conv.inner = untag_ptr(obj);
38232         obj_conv.is_owned = ptr_is_owned(obj);
38233         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38234         obj_conv.is_owned = false;
38235         LDKCVec_u8Z ret_var = OnionMessage_write(&obj_conv);
38236         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38237         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38238         CVec_u8Z_free(ret_var);
38239         return ret_arr;
38240 }
38241
38242 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
38243         LDKPing obj_conv;
38244         obj_conv.inner = untag_ptr(obj);
38245         obj_conv.is_owned = ptr_is_owned(obj);
38246         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38247         obj_conv.is_owned = false;
38248         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
38249         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38250         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38251         CVec_u8Z_free(ret_var);
38252         return ret_arr;
38253 }
38254
38255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38256         LDKu8slice ser_ref;
38257         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38258         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38259         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
38260         *ret_conv = Ping_read(ser_ref);
38261         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38262         return tag_ptr(ret_conv, true);
38263 }
38264
38265 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
38266         LDKPong obj_conv;
38267         obj_conv.inner = untag_ptr(obj);
38268         obj_conv.is_owned = ptr_is_owned(obj);
38269         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38270         obj_conv.is_owned = false;
38271         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
38272         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38273         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38274         CVec_u8Z_free(ret_var);
38275         return ret_arr;
38276 }
38277
38278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38279         LDKu8slice ser_ref;
38280         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38281         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38282         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
38283         *ret_conv = Pong_read(ser_ref);
38284         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38285         return tag_ptr(ret_conv, true);
38286 }
38287
38288 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
38289         LDKUnsignedChannelAnnouncement obj_conv;
38290         obj_conv.inner = untag_ptr(obj);
38291         obj_conv.is_owned = ptr_is_owned(obj);
38292         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38293         obj_conv.is_owned = false;
38294         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
38295         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38296         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38297         CVec_u8Z_free(ret_var);
38298         return ret_arr;
38299 }
38300
38301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38302         LDKu8slice ser_ref;
38303         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38304         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38305         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
38306         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
38307         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38308         return tag_ptr(ret_conv, true);
38309 }
38310
38311 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
38312         LDKChannelAnnouncement obj_conv;
38313         obj_conv.inner = untag_ptr(obj);
38314         obj_conv.is_owned = ptr_is_owned(obj);
38315         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38316         obj_conv.is_owned = false;
38317         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
38318         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38319         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38320         CVec_u8Z_free(ret_var);
38321         return ret_arr;
38322 }
38323
38324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38325         LDKu8slice ser_ref;
38326         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38327         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38328         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
38329         *ret_conv = ChannelAnnouncement_read(ser_ref);
38330         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38331         return tag_ptr(ret_conv, true);
38332 }
38333
38334 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
38335         LDKUnsignedChannelUpdate obj_conv;
38336         obj_conv.inner = untag_ptr(obj);
38337         obj_conv.is_owned = ptr_is_owned(obj);
38338         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38339         obj_conv.is_owned = false;
38340         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
38341         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38342         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38343         CVec_u8Z_free(ret_var);
38344         return ret_arr;
38345 }
38346
38347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38348         LDKu8slice ser_ref;
38349         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38350         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38351         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
38352         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
38353         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38354         return tag_ptr(ret_conv, true);
38355 }
38356
38357 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
38358         LDKChannelUpdate obj_conv;
38359         obj_conv.inner = untag_ptr(obj);
38360         obj_conv.is_owned = ptr_is_owned(obj);
38361         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38362         obj_conv.is_owned = false;
38363         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
38364         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38365         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38366         CVec_u8Z_free(ret_var);
38367         return ret_arr;
38368 }
38369
38370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38371         LDKu8slice ser_ref;
38372         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38373         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38374         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
38375         *ret_conv = ChannelUpdate_read(ser_ref);
38376         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38377         return tag_ptr(ret_conv, true);
38378 }
38379
38380 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
38381         LDKErrorMessage obj_conv;
38382         obj_conv.inner = untag_ptr(obj);
38383         obj_conv.is_owned = ptr_is_owned(obj);
38384         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38385         obj_conv.is_owned = false;
38386         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
38387         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38388         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38389         CVec_u8Z_free(ret_var);
38390         return ret_arr;
38391 }
38392
38393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38394         LDKu8slice ser_ref;
38395         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38396         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38397         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
38398         *ret_conv = ErrorMessage_read(ser_ref);
38399         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38400         return tag_ptr(ret_conv, true);
38401 }
38402
38403 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
38404         LDKWarningMessage obj_conv;
38405         obj_conv.inner = untag_ptr(obj);
38406         obj_conv.is_owned = ptr_is_owned(obj);
38407         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38408         obj_conv.is_owned = false;
38409         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
38410         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38411         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38412         CVec_u8Z_free(ret_var);
38413         return ret_arr;
38414 }
38415
38416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38417         LDKu8slice ser_ref;
38418         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38419         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38420         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
38421         *ret_conv = WarningMessage_read(ser_ref);
38422         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38423         return tag_ptr(ret_conv, true);
38424 }
38425
38426 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
38427         LDKUnsignedNodeAnnouncement obj_conv;
38428         obj_conv.inner = untag_ptr(obj);
38429         obj_conv.is_owned = ptr_is_owned(obj);
38430         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38431         obj_conv.is_owned = false;
38432         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
38433         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38434         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38435         CVec_u8Z_free(ret_var);
38436         return ret_arr;
38437 }
38438
38439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38440         LDKu8slice ser_ref;
38441         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38442         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38443         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
38444         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
38445         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38446         return tag_ptr(ret_conv, true);
38447 }
38448
38449 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
38450         LDKNodeAnnouncement obj_conv;
38451         obj_conv.inner = untag_ptr(obj);
38452         obj_conv.is_owned = ptr_is_owned(obj);
38453         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38454         obj_conv.is_owned = false;
38455         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
38456         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38457         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38458         CVec_u8Z_free(ret_var);
38459         return ret_arr;
38460 }
38461
38462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38463         LDKu8slice ser_ref;
38464         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38465         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38466         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
38467         *ret_conv = NodeAnnouncement_read(ser_ref);
38468         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38469         return tag_ptr(ret_conv, true);
38470 }
38471
38472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38473         LDKu8slice ser_ref;
38474         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38475         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38476         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
38477         *ret_conv = QueryShortChannelIds_read(ser_ref);
38478         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38479         return tag_ptr(ret_conv, true);
38480 }
38481
38482 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
38483         LDKQueryShortChannelIds obj_conv;
38484         obj_conv.inner = untag_ptr(obj);
38485         obj_conv.is_owned = ptr_is_owned(obj);
38486         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38487         obj_conv.is_owned = false;
38488         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
38489         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38490         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38491         CVec_u8Z_free(ret_var);
38492         return ret_arr;
38493 }
38494
38495 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
38496         LDKReplyShortChannelIdsEnd obj_conv;
38497         obj_conv.inner = untag_ptr(obj);
38498         obj_conv.is_owned = ptr_is_owned(obj);
38499         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38500         obj_conv.is_owned = false;
38501         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
38502         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38503         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38504         CVec_u8Z_free(ret_var);
38505         return ret_arr;
38506 }
38507
38508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38509         LDKu8slice ser_ref;
38510         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38511         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38512         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
38513         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
38514         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38515         return tag_ptr(ret_conv, true);
38516 }
38517
38518 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
38519         LDKQueryChannelRange this_arg_conv;
38520         this_arg_conv.inner = untag_ptr(this_arg);
38521         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38523         this_arg_conv.is_owned = false;
38524         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
38525         return ret_conv;
38526 }
38527
38528 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
38529         LDKQueryChannelRange obj_conv;
38530         obj_conv.inner = untag_ptr(obj);
38531         obj_conv.is_owned = ptr_is_owned(obj);
38532         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38533         obj_conv.is_owned = false;
38534         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
38535         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38536         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38537         CVec_u8Z_free(ret_var);
38538         return ret_arr;
38539 }
38540
38541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38542         LDKu8slice ser_ref;
38543         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38544         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38545         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
38546         *ret_conv = QueryChannelRange_read(ser_ref);
38547         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38548         return tag_ptr(ret_conv, true);
38549 }
38550
38551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38552         LDKu8slice ser_ref;
38553         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38554         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38555         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
38556         *ret_conv = ReplyChannelRange_read(ser_ref);
38557         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38558         return tag_ptr(ret_conv, true);
38559 }
38560
38561 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
38562         LDKReplyChannelRange obj_conv;
38563         obj_conv.inner = untag_ptr(obj);
38564         obj_conv.is_owned = ptr_is_owned(obj);
38565         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38566         obj_conv.is_owned = false;
38567         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
38568         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38569         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38570         CVec_u8Z_free(ret_var);
38571         return ret_arr;
38572 }
38573
38574 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
38575         LDKGossipTimestampFilter obj_conv;
38576         obj_conv.inner = untag_ptr(obj);
38577         obj_conv.is_owned = ptr_is_owned(obj);
38578         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
38579         obj_conv.is_owned = false;
38580         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
38581         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38582         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38583         CVec_u8Z_free(ret_var);
38584         return ret_arr;
38585 }
38586
38587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
38588         LDKu8slice ser_ref;
38589         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
38590         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
38591         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
38592         *ret_conv = GossipTimestampFilter_read(ser_ref);
38593         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
38594         return tag_ptr(ret_conv, true);
38595 }
38596
38597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38598         if (!ptr_is_owned(this_ptr)) return;
38599         void* this_ptr_ptr = untag_ptr(this_ptr);
38600         CHECK_ACCESS(this_ptr_ptr);
38601         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
38602         FREE(untag_ptr(this_ptr));
38603         CustomMessageHandler_free(this_ptr_conv);
38604 }
38605
38606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38607         LDKIgnoringMessageHandler this_obj_conv;
38608         this_obj_conv.inner = untag_ptr(this_obj);
38609         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38611         IgnoringMessageHandler_free(this_obj_conv);
38612 }
38613
38614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
38615         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
38616         int64_t ret_ref = 0;
38617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38618         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38619         return ret_ref;
38620 }
38621
38622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
38623         LDKIgnoringMessageHandler this_arg_conv;
38624         this_arg_conv.inner = untag_ptr(this_arg);
38625         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38627         this_arg_conv.is_owned = false;
38628         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
38629         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
38630         return tag_ptr(ret_ret, true);
38631 }
38632
38633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
38634         LDKIgnoringMessageHandler this_arg_conv;
38635         this_arg_conv.inner = untag_ptr(this_arg);
38636         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38638         this_arg_conv.is_owned = false;
38639         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
38640         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
38641         return tag_ptr(ret_ret, true);
38642 }
38643
38644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
38645         LDKIgnoringMessageHandler this_arg_conv;
38646         this_arg_conv.inner = untag_ptr(this_arg);
38647         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38649         this_arg_conv.is_owned = false;
38650         LDKOnionMessageProvider* ret_ret = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
38651         *ret_ret = IgnoringMessageHandler_as_OnionMessageProvider(&this_arg_conv);
38652         return tag_ptr(ret_ret, true);
38653 }
38654
38655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1OnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
38656         LDKIgnoringMessageHandler this_arg_conv;
38657         this_arg_conv.inner = untag_ptr(this_arg);
38658         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38660         this_arg_conv.is_owned = false;
38661         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
38662         *ret_ret = IgnoringMessageHandler_as_OnionMessageHandler(&this_arg_conv);
38663         return tag_ptr(ret_ret, true);
38664 }
38665
38666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
38667         LDKIgnoringMessageHandler this_arg_conv;
38668         this_arg_conv.inner = untag_ptr(this_arg);
38669         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38671         this_arg_conv.is_owned = false;
38672         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
38673         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
38674         return tag_ptr(ret_ret, true);
38675 }
38676
38677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
38678         LDKIgnoringMessageHandler this_arg_conv;
38679         this_arg_conv.inner = untag_ptr(this_arg);
38680         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38682         this_arg_conv.is_owned = false;
38683         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
38684         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
38685         return tag_ptr(ret_ret, true);
38686 }
38687
38688 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38689         LDKErroringMessageHandler this_obj_conv;
38690         this_obj_conv.inner = untag_ptr(this_obj);
38691         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38693         ErroringMessageHandler_free(this_obj_conv);
38694 }
38695
38696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
38697         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
38698         int64_t ret_ref = 0;
38699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38700         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38701         return ret_ref;
38702 }
38703
38704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
38705         LDKErroringMessageHandler this_arg_conv;
38706         this_arg_conv.inner = untag_ptr(this_arg);
38707         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38709         this_arg_conv.is_owned = false;
38710         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
38711         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
38712         return tag_ptr(ret_ret, true);
38713 }
38714
38715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
38716         LDKErroringMessageHandler this_arg_conv;
38717         this_arg_conv.inner = untag_ptr(this_arg);
38718         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38720         this_arg_conv.is_owned = false;
38721         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
38722         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
38723         return tag_ptr(ret_ret, true);
38724 }
38725
38726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38727         LDKMessageHandler this_obj_conv;
38728         this_obj_conv.inner = untag_ptr(this_obj);
38729         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38731         MessageHandler_free(this_obj_conv);
38732 }
38733
38734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
38735         LDKMessageHandler this_ptr_conv;
38736         this_ptr_conv.inner = untag_ptr(this_ptr);
38737         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38739         this_ptr_conv.is_owned = false;
38740         // WARNING: This object doesn't live past this scope, needs clone!
38741         int64_t ret_ret = tag_ptr(MessageHandler_get_chan_handler(&this_ptr_conv), false);
38742         return ret_ret;
38743 }
38744
38745 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38746         LDKMessageHandler this_ptr_conv;
38747         this_ptr_conv.inner = untag_ptr(this_ptr);
38748         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38750         this_ptr_conv.is_owned = false;
38751         void* val_ptr = untag_ptr(val);
38752         CHECK_ACCESS(val_ptr);
38753         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
38754         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
38755                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38756                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
38757         }
38758         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
38759 }
38760
38761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
38762         LDKMessageHandler this_ptr_conv;
38763         this_ptr_conv.inner = untag_ptr(this_ptr);
38764         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38766         this_ptr_conv.is_owned = false;
38767         // WARNING: This object doesn't live past this scope, needs clone!
38768         int64_t ret_ret = tag_ptr(MessageHandler_get_route_handler(&this_ptr_conv), false);
38769         return ret_ret;
38770 }
38771
38772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38773         LDKMessageHandler this_ptr_conv;
38774         this_ptr_conv.inner = untag_ptr(this_ptr);
38775         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38777         this_ptr_conv.is_owned = false;
38778         void* val_ptr = untag_ptr(val);
38779         CHECK_ACCESS(val_ptr);
38780         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
38781         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
38782                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38783                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
38784         }
38785         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
38786 }
38787
38788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1onion_1message_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
38789         LDKMessageHandler this_ptr_conv;
38790         this_ptr_conv.inner = untag_ptr(this_ptr);
38791         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38793         this_ptr_conv.is_owned = false;
38794         // WARNING: This object doesn't live past this scope, needs clone!
38795         int64_t ret_ret = tag_ptr(MessageHandler_get_onion_message_handler(&this_ptr_conv), false);
38796         return ret_ret;
38797 }
38798
38799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1onion_1message_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38800         LDKMessageHandler this_ptr_conv;
38801         this_ptr_conv.inner = untag_ptr(this_ptr);
38802         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38804         this_ptr_conv.is_owned = false;
38805         void* val_ptr = untag_ptr(val);
38806         CHECK_ACCESS(val_ptr);
38807         LDKOnionMessageHandler val_conv = *(LDKOnionMessageHandler*)(val_ptr);
38808         if (val_conv.free == LDKOnionMessageHandler_JCalls_free) {
38809                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38810                 LDKOnionMessageHandler_JCalls_cloned(&val_conv);
38811         }
38812         MessageHandler_set_onion_message_handler(&this_ptr_conv, val_conv);
38813 }
38814
38815 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, int64_t onion_message_handler_arg) {
38816         void* chan_handler_arg_ptr = untag_ptr(chan_handler_arg);
38817         CHECK_ACCESS(chan_handler_arg_ptr);
38818         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
38819         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
38820                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38821                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
38822         }
38823         void* route_handler_arg_ptr = untag_ptr(route_handler_arg);
38824         CHECK_ACCESS(route_handler_arg_ptr);
38825         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
38826         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
38827                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38828                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
38829         }
38830         void* onion_message_handler_arg_ptr = untag_ptr(onion_message_handler_arg);
38831         CHECK_ACCESS(onion_message_handler_arg_ptr);
38832         LDKOnionMessageHandler onion_message_handler_arg_conv = *(LDKOnionMessageHandler*)(onion_message_handler_arg_ptr);
38833         if (onion_message_handler_arg_conv.free == LDKOnionMessageHandler_JCalls_free) {
38834                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38835                 LDKOnionMessageHandler_JCalls_cloned(&onion_message_handler_arg_conv);
38836         }
38837         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv, onion_message_handler_arg_conv);
38838         int64_t ret_ref = 0;
38839         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38840         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38841         return ret_ref;
38842 }
38843
38844 static inline uint64_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
38845         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
38846         *ret_ret = SocketDescriptor_clone(arg);
38847         return tag_ptr(ret_ret, true);
38848 }
38849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38850         void* arg_ptr = untag_ptr(arg);
38851         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
38852         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
38853         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
38854         return ret_conv;
38855 }
38856
38857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38858         void* orig_ptr = untag_ptr(orig);
38859         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
38860         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
38861         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
38862         *ret_ret = SocketDescriptor_clone(orig_conv);
38863         return tag_ptr(ret_ret, true);
38864 }
38865
38866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38867         if (!ptr_is_owned(this_ptr)) return;
38868         void* this_ptr_ptr = untag_ptr(this_ptr);
38869         CHECK_ACCESS(this_ptr_ptr);
38870         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
38871         FREE(untag_ptr(this_ptr));
38872         SocketDescriptor_free(this_ptr_conv);
38873 }
38874
38875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38876         LDKPeerHandleError this_obj_conv;
38877         this_obj_conv.inner = untag_ptr(this_obj);
38878         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38880         PeerHandleError_free(this_obj_conv);
38881 }
38882
38883 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
38884         LDKPeerHandleError this_ptr_conv;
38885         this_ptr_conv.inner = untag_ptr(this_ptr);
38886         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38888         this_ptr_conv.is_owned = false;
38889         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
38890         return ret_conv;
38891 }
38892
38893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
38894         LDKPeerHandleError this_ptr_conv;
38895         this_ptr_conv.inner = untag_ptr(this_ptr);
38896         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38898         this_ptr_conv.is_owned = false;
38899         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
38900 }
38901
38902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
38903         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
38904         int64_t ret_ref = 0;
38905         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38906         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38907         return ret_ref;
38908 }
38909
38910 static inline uint64_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
38911         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
38912         int64_t ret_ref = 0;
38913         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38914         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38915         return ret_ref;
38916 }
38917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38918         LDKPeerHandleError arg_conv;
38919         arg_conv.inner = untag_ptr(arg);
38920         arg_conv.is_owned = ptr_is_owned(arg);
38921         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38922         arg_conv.is_owned = false;
38923         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
38924         return ret_conv;
38925 }
38926
38927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38928         LDKPeerHandleError orig_conv;
38929         orig_conv.inner = untag_ptr(orig);
38930         orig_conv.is_owned = ptr_is_owned(orig);
38931         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38932         orig_conv.is_owned = false;
38933         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
38934         int64_t ret_ref = 0;
38935         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38936         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38937         return ret_ref;
38938 }
38939
38940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38941         LDKPeerManager this_obj_conv;
38942         this_obj_conv.inner = untag_ptr(this_obj);
38943         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38945         PeerManager_free(this_obj_conv);
38946 }
38947
38948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new(JNIEnv *env, jclass clz, int64_t message_handler, int8_tArray our_node_secret, int64_t current_time, int8_tArray ephemeral_random_data, int64_t logger, int64_t custom_message_handler) {
38949         LDKMessageHandler message_handler_conv;
38950         message_handler_conv.inner = untag_ptr(message_handler);
38951         message_handler_conv.is_owned = ptr_is_owned(message_handler);
38952         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
38953         // WARNING: we need a move here but no clone is available for LDKMessageHandler
38954         
38955         LDKSecretKey our_node_secret_ref;
38956         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
38957         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
38958         unsigned char ephemeral_random_data_arr[32];
38959         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
38960         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
38961         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
38962         void* logger_ptr = untag_ptr(logger);
38963         CHECK_ACCESS(logger_ptr);
38964         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
38965         if (logger_conv.free == LDKLogger_JCalls_free) {
38966                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38967                 LDKLogger_JCalls_cloned(&logger_conv);
38968         }
38969         void* custom_message_handler_ptr = untag_ptr(custom_message_handler);
38970         CHECK_ACCESS(custom_message_handler_ptr);
38971         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
38972         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
38973                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
38974                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
38975         }
38976         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, current_time, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
38977         int64_t ret_ref = 0;
38978         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38979         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38980         return ret_ref;
38981 }
38982
38983 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
38984         LDKPeerManager this_arg_conv;
38985         this_arg_conv.inner = untag_ptr(this_arg);
38986         this_arg_conv.is_owned = ptr_is_owned(this_arg);
38987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
38988         this_arg_conv.is_owned = false;
38989         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
38990         jobjectArray ret_arr = NULL;
38991         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
38992         ;
38993         for (size_t i = 0; i < ret_var.datalen; i++) {
38994                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
38995                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
38996                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
38997         }
38998         
38999         FREE(ret_var.data);
39000         return ret_arr;
39001 }
39002
39003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1outbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t descriptor, int64_t remote_network_address) {
39004         LDKPeerManager this_arg_conv;
39005         this_arg_conv.inner = untag_ptr(this_arg);
39006         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39008         this_arg_conv.is_owned = false;
39009         LDKPublicKey their_node_id_ref;
39010         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
39011         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
39012         void* descriptor_ptr = untag_ptr(descriptor);
39013         CHECK_ACCESS(descriptor_ptr);
39014         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
39015         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
39016                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39017                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
39018         }
39019         void* remote_network_address_ptr = untag_ptr(remote_network_address);
39020         CHECK_ACCESS(remote_network_address_ptr);
39021         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
39022         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
39023         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
39024         return tag_ptr(ret_conv, true);
39025 }
39026
39027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor, int64_t remote_network_address) {
39028         LDKPeerManager this_arg_conv;
39029         this_arg_conv.inner = untag_ptr(this_arg);
39030         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39032         this_arg_conv.is_owned = false;
39033         void* descriptor_ptr = untag_ptr(descriptor);
39034         CHECK_ACCESS(descriptor_ptr);
39035         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
39036         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
39037                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39038                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
39039         }
39040         void* remote_network_address_ptr = untag_ptr(remote_network_address);
39041         CHECK_ACCESS(remote_network_address_ptr);
39042         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
39043         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
39044         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
39045         return tag_ptr(ret_conv, true);
39046 }
39047
39048 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) {
39049         LDKPeerManager this_arg_conv;
39050         this_arg_conv.inner = untag_ptr(this_arg);
39051         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39053         this_arg_conv.is_owned = false;
39054         void* descriptor_ptr = untag_ptr(descriptor);
39055         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
39056         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
39057         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
39058         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
39059         return tag_ptr(ret_conv, true);
39060 }
39061
39062 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) {
39063         LDKPeerManager this_arg_conv;
39064         this_arg_conv.inner = untag_ptr(this_arg);
39065         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39067         this_arg_conv.is_owned = false;
39068         void* peer_descriptor_ptr = untag_ptr(peer_descriptor);
39069         if (ptr_is_owned(peer_descriptor)) { CHECK_ACCESS(peer_descriptor_ptr); }
39070         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
39071         LDKu8slice data_ref;
39072         data_ref.datalen = (*env)->GetArrayLength(env, data);
39073         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
39074         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
39075         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
39076         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
39077         return tag_ptr(ret_conv, true);
39078 }
39079
39080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
39081         LDKPeerManager this_arg_conv;
39082         this_arg_conv.inner = untag_ptr(this_arg);
39083         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39085         this_arg_conv.is_owned = false;
39086         PeerManager_process_events(&this_arg_conv);
39087 }
39088
39089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
39090         LDKPeerManager this_arg_conv;
39091         this_arg_conv.inner = untag_ptr(this_arg);
39092         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39094         this_arg_conv.is_owned = false;
39095         void* descriptor_ptr = untag_ptr(descriptor);
39096         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
39097         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
39098         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
39099 }
39100
39101 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) {
39102         LDKPeerManager this_arg_conv;
39103         this_arg_conv.inner = untag_ptr(this_arg);
39104         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39106         this_arg_conv.is_owned = false;
39107         LDKPublicKey node_id_ref;
39108         CHECK((*env)->GetArrayLength(env, node_id) == 33);
39109         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
39110         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
39111 }
39112
39113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
39114         LDKPeerManager this_arg_conv;
39115         this_arg_conv.inner = untag_ptr(this_arg);
39116         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39118         this_arg_conv.is_owned = false;
39119         PeerManager_disconnect_all_peers(&this_arg_conv);
39120 }
39121
39122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
39123         LDKPeerManager this_arg_conv;
39124         this_arg_conv.inner = untag_ptr(this_arg);
39125         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39127         this_arg_conv.is_owned = false;
39128         PeerManager_timer_tick_occurred(&this_arg_conv);
39129 }
39130
39131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray rgb, int8_tArray alias, int64_tArray addresses) {
39132         LDKPeerManager this_arg_conv;
39133         this_arg_conv.inner = untag_ptr(this_arg);
39134         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39136         this_arg_conv.is_owned = false;
39137         LDKThreeBytes rgb_ref;
39138         CHECK((*env)->GetArrayLength(env, rgb) == 3);
39139         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
39140         LDKThirtyTwoBytes alias_ref;
39141         CHECK((*env)->GetArrayLength(env, alias) == 32);
39142         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
39143         LDKCVec_NetAddressZ addresses_constr;
39144         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
39145         if (addresses_constr.datalen > 0)
39146                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
39147         else
39148                 addresses_constr.data = NULL;
39149         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
39150         for (size_t m = 0; m < addresses_constr.datalen; m++) {
39151                 int64_t addresses_conv_12 = addresses_vals[m];
39152                 void* addresses_conv_12_ptr = untag_ptr(addresses_conv_12);
39153                 CHECK_ACCESS(addresses_conv_12_ptr);
39154                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
39155                 addresses_constr.data[m] = addresses_conv_12_conv;
39156         }
39157         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
39158         PeerManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
39159 }
39160
39161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
39162         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
39163         return ret_conv;
39164 }
39165
39166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
39167         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
39168         return ret_conv;
39169 }
39170
39171 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
39172         unsigned char commitment_seed_arr[32];
39173         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
39174         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
39175         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
39176         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39177         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
39178         return ret_arr;
39179 }
39180
39181 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) {
39182         LDKCVec_u8Z to_holder_script_ref;
39183         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
39184         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
39185         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
39186         LDKCVec_u8Z to_counterparty_script_ref;
39187         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
39188         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
39189         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
39190         LDKOutPoint funding_outpoint_conv;
39191         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
39192         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
39193         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
39194         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
39195         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);
39196         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39197         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39198         Transaction_free(ret_var);
39199         return ret_arr;
39200 }
39201
39202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39203         LDKCounterpartyCommitmentSecrets this_obj_conv;
39204         this_obj_conv.inner = untag_ptr(this_obj);
39205         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39207         CounterpartyCommitmentSecrets_free(this_obj_conv);
39208 }
39209
39210 static inline uint64_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
39211         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
39212         int64_t ret_ref = 0;
39213         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39214         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39215         return ret_ref;
39216 }
39217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39218         LDKCounterpartyCommitmentSecrets arg_conv;
39219         arg_conv.inner = untag_ptr(arg);
39220         arg_conv.is_owned = ptr_is_owned(arg);
39221         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39222         arg_conv.is_owned = false;
39223         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
39224         return ret_conv;
39225 }
39226
39227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39228         LDKCounterpartyCommitmentSecrets orig_conv;
39229         orig_conv.inner = untag_ptr(orig);
39230         orig_conv.is_owned = ptr_is_owned(orig);
39231         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39232         orig_conv.is_owned = false;
39233         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
39234         int64_t ret_ref = 0;
39235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39236         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39237         return ret_ref;
39238 }
39239
39240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
39241         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
39242         int64_t ret_ref = 0;
39243         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39244         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39245         return ret_ref;
39246 }
39247
39248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
39249         LDKCounterpartyCommitmentSecrets this_arg_conv;
39250         this_arg_conv.inner = untag_ptr(this_arg);
39251         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39253         this_arg_conv.is_owned = false;
39254         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
39255         return ret_conv;
39256 }
39257
39258 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) {
39259         LDKCounterpartyCommitmentSecrets this_arg_conv;
39260         this_arg_conv.inner = untag_ptr(this_arg);
39261         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39263         this_arg_conv.is_owned = false;
39264         LDKThirtyTwoBytes secret_ref;
39265         CHECK((*env)->GetArrayLength(env, secret) == 32);
39266         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
39267         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
39268         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
39269         return tag_ptr(ret_conv, true);
39270 }
39271
39272 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
39273         LDKCounterpartyCommitmentSecrets this_arg_conv;
39274         this_arg_conv.inner = untag_ptr(this_arg);
39275         this_arg_conv.is_owned = ptr_is_owned(this_arg);
39276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39277         this_arg_conv.is_owned = false;
39278         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39279         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
39280         return ret_arr;
39281 }
39282
39283 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
39284         LDKCounterpartyCommitmentSecrets obj_conv;
39285         obj_conv.inner = untag_ptr(obj);
39286         obj_conv.is_owned = ptr_is_owned(obj);
39287         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39288         obj_conv.is_owned = false;
39289         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
39290         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39291         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39292         CVec_u8Z_free(ret_var);
39293         return ret_arr;
39294 }
39295
39296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39297         LDKu8slice ser_ref;
39298         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39299         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39300         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
39301         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
39302         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39303         return tag_ptr(ret_conv, true);
39304 }
39305
39306 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) {
39307         LDKPublicKey per_commitment_point_ref;
39308         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
39309         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
39310         unsigned char base_secret_arr[32];
39311         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
39312         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
39313         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
39314         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
39315         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
39316         return tag_ptr(ret_conv, true);
39317 }
39318
39319 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) {
39320         LDKPublicKey per_commitment_point_ref;
39321         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
39322         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
39323         LDKPublicKey base_point_ref;
39324         CHECK((*env)->GetArrayLength(env, base_point) == 33);
39325         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
39326         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
39327         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
39328         return tag_ptr(ret_conv, true);
39329 }
39330
39331 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) {
39332         unsigned char per_commitment_secret_arr[32];
39333         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
39334         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
39335         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
39336         unsigned char countersignatory_revocation_base_secret_arr[32];
39337         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
39338         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
39339         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
39340         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
39341         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
39342         return tag_ptr(ret_conv, true);
39343 }
39344
39345 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) {
39346         LDKPublicKey per_commitment_point_ref;
39347         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
39348         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
39349         LDKPublicKey countersignatory_revocation_base_point_ref;
39350         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
39351         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
39352         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
39353         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
39354         return tag_ptr(ret_conv, true);
39355 }
39356
39357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39358         LDKTxCreationKeys this_obj_conv;
39359         this_obj_conv.inner = untag_ptr(this_obj);
39360         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39362         TxCreationKeys_free(this_obj_conv);
39363 }
39364
39365 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
39366         LDKTxCreationKeys this_ptr_conv;
39367         this_ptr_conv.inner = untag_ptr(this_ptr);
39368         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39370         this_ptr_conv.is_owned = false;
39371         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39372         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
39373         return ret_arr;
39374 }
39375
39376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39377         LDKTxCreationKeys this_ptr_conv;
39378         this_ptr_conv.inner = untag_ptr(this_ptr);
39379         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39381         this_ptr_conv.is_owned = false;
39382         LDKPublicKey val_ref;
39383         CHECK((*env)->GetArrayLength(env, val) == 33);
39384         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39385         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
39386 }
39387
39388 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
39389         LDKTxCreationKeys this_ptr_conv;
39390         this_ptr_conv.inner = untag_ptr(this_ptr);
39391         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39393         this_ptr_conv.is_owned = false;
39394         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39395         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
39396         return ret_arr;
39397 }
39398
39399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39400         LDKTxCreationKeys this_ptr_conv;
39401         this_ptr_conv.inner = untag_ptr(this_ptr);
39402         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39404         this_ptr_conv.is_owned = false;
39405         LDKPublicKey val_ref;
39406         CHECK((*env)->GetArrayLength(env, val) == 33);
39407         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39408         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
39409 }
39410
39411 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
39412         LDKTxCreationKeys this_ptr_conv;
39413         this_ptr_conv.inner = untag_ptr(this_ptr);
39414         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39416         this_ptr_conv.is_owned = false;
39417         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39418         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
39419         return ret_arr;
39420 }
39421
39422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39423         LDKTxCreationKeys this_ptr_conv;
39424         this_ptr_conv.inner = untag_ptr(this_ptr);
39425         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39427         this_ptr_conv.is_owned = false;
39428         LDKPublicKey val_ref;
39429         CHECK((*env)->GetArrayLength(env, val) == 33);
39430         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39431         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
39432 }
39433
39434 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
39435         LDKTxCreationKeys this_ptr_conv;
39436         this_ptr_conv.inner = untag_ptr(this_ptr);
39437         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39439         this_ptr_conv.is_owned = false;
39440         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39441         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
39442         return ret_arr;
39443 }
39444
39445 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39446         LDKTxCreationKeys this_ptr_conv;
39447         this_ptr_conv.inner = untag_ptr(this_ptr);
39448         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39450         this_ptr_conv.is_owned = false;
39451         LDKPublicKey val_ref;
39452         CHECK((*env)->GetArrayLength(env, val) == 33);
39453         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39454         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
39455 }
39456
39457 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
39458         LDKTxCreationKeys this_ptr_conv;
39459         this_ptr_conv.inner = untag_ptr(this_ptr);
39460         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39462         this_ptr_conv.is_owned = false;
39463         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39464         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
39465         return ret_arr;
39466 }
39467
39468 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) {
39469         LDKTxCreationKeys this_ptr_conv;
39470         this_ptr_conv.inner = untag_ptr(this_ptr);
39471         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39473         this_ptr_conv.is_owned = false;
39474         LDKPublicKey val_ref;
39475         CHECK((*env)->GetArrayLength(env, val) == 33);
39476         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39477         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
39478 }
39479
39480 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) {
39481         LDKPublicKey per_commitment_point_arg_ref;
39482         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
39483         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
39484         LDKPublicKey revocation_key_arg_ref;
39485         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
39486         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
39487         LDKPublicKey broadcaster_htlc_key_arg_ref;
39488         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
39489         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
39490         LDKPublicKey countersignatory_htlc_key_arg_ref;
39491         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
39492         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
39493         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
39494         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
39495         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
39496         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);
39497         int64_t ret_ref = 0;
39498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39499         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39500         return ret_ref;
39501 }
39502
39503 static inline uint64_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
39504         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
39505         int64_t ret_ref = 0;
39506         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39507         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39508         return ret_ref;
39509 }
39510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39511         LDKTxCreationKeys arg_conv;
39512         arg_conv.inner = untag_ptr(arg);
39513         arg_conv.is_owned = ptr_is_owned(arg);
39514         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39515         arg_conv.is_owned = false;
39516         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
39517         return ret_conv;
39518 }
39519
39520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39521         LDKTxCreationKeys orig_conv;
39522         orig_conv.inner = untag_ptr(orig);
39523         orig_conv.is_owned = ptr_is_owned(orig);
39524         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39525         orig_conv.is_owned = false;
39526         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
39527         int64_t ret_ref = 0;
39528         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39529         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39530         return ret_ref;
39531 }
39532
39533 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
39534         LDKTxCreationKeys obj_conv;
39535         obj_conv.inner = untag_ptr(obj);
39536         obj_conv.is_owned = ptr_is_owned(obj);
39537         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39538         obj_conv.is_owned = false;
39539         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
39540         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39541         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39542         CVec_u8Z_free(ret_var);
39543         return ret_arr;
39544 }
39545
39546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39547         LDKu8slice ser_ref;
39548         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39549         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39550         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
39551         *ret_conv = TxCreationKeys_read(ser_ref);
39552         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39553         return tag_ptr(ret_conv, true);
39554 }
39555
39556 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39557         LDKChannelPublicKeys this_obj_conv;
39558         this_obj_conv.inner = untag_ptr(this_obj);
39559         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39561         ChannelPublicKeys_free(this_obj_conv);
39562 }
39563
39564 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
39565         LDKChannelPublicKeys this_ptr_conv;
39566         this_ptr_conv.inner = untag_ptr(this_ptr);
39567         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39569         this_ptr_conv.is_owned = false;
39570         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39571         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
39572         return ret_arr;
39573 }
39574
39575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39576         LDKChannelPublicKeys this_ptr_conv;
39577         this_ptr_conv.inner = untag_ptr(this_ptr);
39578         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39580         this_ptr_conv.is_owned = false;
39581         LDKPublicKey val_ref;
39582         CHECK((*env)->GetArrayLength(env, val) == 33);
39583         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39584         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
39585 }
39586
39587 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
39588         LDKChannelPublicKeys this_ptr_conv;
39589         this_ptr_conv.inner = untag_ptr(this_ptr);
39590         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39592         this_ptr_conv.is_owned = false;
39593         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39594         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
39595         return ret_arr;
39596 }
39597
39598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39599         LDKChannelPublicKeys this_ptr_conv;
39600         this_ptr_conv.inner = untag_ptr(this_ptr);
39601         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39603         this_ptr_conv.is_owned = false;
39604         LDKPublicKey val_ref;
39605         CHECK((*env)->GetArrayLength(env, val) == 33);
39606         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39607         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
39608 }
39609
39610 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
39611         LDKChannelPublicKeys this_ptr_conv;
39612         this_ptr_conv.inner = untag_ptr(this_ptr);
39613         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39614         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39615         this_ptr_conv.is_owned = false;
39616         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39617         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
39618         return ret_arr;
39619 }
39620
39621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39622         LDKChannelPublicKeys this_ptr_conv;
39623         this_ptr_conv.inner = untag_ptr(this_ptr);
39624         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39626         this_ptr_conv.is_owned = false;
39627         LDKPublicKey val_ref;
39628         CHECK((*env)->GetArrayLength(env, val) == 33);
39629         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39630         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
39631 }
39632
39633 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
39634         LDKChannelPublicKeys this_ptr_conv;
39635         this_ptr_conv.inner = untag_ptr(this_ptr);
39636         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39638         this_ptr_conv.is_owned = false;
39639         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39640         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
39641         return ret_arr;
39642 }
39643
39644 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39645         LDKChannelPublicKeys this_ptr_conv;
39646         this_ptr_conv.inner = untag_ptr(this_ptr);
39647         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39649         this_ptr_conv.is_owned = false;
39650         LDKPublicKey val_ref;
39651         CHECK((*env)->GetArrayLength(env, val) == 33);
39652         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39653         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
39654 }
39655
39656 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
39657         LDKChannelPublicKeys this_ptr_conv;
39658         this_ptr_conv.inner = untag_ptr(this_ptr);
39659         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39661         this_ptr_conv.is_owned = false;
39662         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39663         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
39664         return ret_arr;
39665 }
39666
39667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39668         LDKChannelPublicKeys this_ptr_conv;
39669         this_ptr_conv.inner = untag_ptr(this_ptr);
39670         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39672         this_ptr_conv.is_owned = false;
39673         LDKPublicKey val_ref;
39674         CHECK((*env)->GetArrayLength(env, val) == 33);
39675         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
39676         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
39677 }
39678
39679 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) {
39680         LDKPublicKey funding_pubkey_arg_ref;
39681         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
39682         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
39683         LDKPublicKey revocation_basepoint_arg_ref;
39684         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
39685         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
39686         LDKPublicKey payment_point_arg_ref;
39687         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
39688         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
39689         LDKPublicKey delayed_payment_basepoint_arg_ref;
39690         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
39691         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
39692         LDKPublicKey htlc_basepoint_arg_ref;
39693         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
39694         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
39695         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);
39696         int64_t ret_ref = 0;
39697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39698         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39699         return ret_ref;
39700 }
39701
39702 static inline uint64_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
39703         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
39704         int64_t ret_ref = 0;
39705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39706         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39707         return ret_ref;
39708 }
39709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39710         LDKChannelPublicKeys arg_conv;
39711         arg_conv.inner = untag_ptr(arg);
39712         arg_conv.is_owned = ptr_is_owned(arg);
39713         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39714         arg_conv.is_owned = false;
39715         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
39716         return ret_conv;
39717 }
39718
39719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39720         LDKChannelPublicKeys orig_conv;
39721         orig_conv.inner = untag_ptr(orig);
39722         orig_conv.is_owned = ptr_is_owned(orig);
39723         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39724         orig_conv.is_owned = false;
39725         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
39726         int64_t ret_ref = 0;
39727         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39728         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39729         return ret_ref;
39730 }
39731
39732 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
39733         LDKChannelPublicKeys obj_conv;
39734         obj_conv.inner = untag_ptr(obj);
39735         obj_conv.is_owned = ptr_is_owned(obj);
39736         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39737         obj_conv.is_owned = false;
39738         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
39739         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39740         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39741         CVec_u8Z_free(ret_var);
39742         return ret_arr;
39743 }
39744
39745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39746         LDKu8slice ser_ref;
39747         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39748         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39749         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
39750         *ret_conv = ChannelPublicKeys_read(ser_ref);
39751         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39752         return tag_ptr(ret_conv, true);
39753 }
39754
39755 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) {
39756         LDKPublicKey per_commitment_point_ref;
39757         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
39758         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
39759         LDKPublicKey broadcaster_delayed_payment_base_ref;
39760         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
39761         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
39762         LDKPublicKey broadcaster_htlc_base_ref;
39763         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
39764         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
39765         LDKPublicKey countersignatory_revocation_base_ref;
39766         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
39767         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
39768         LDKPublicKey countersignatory_htlc_base_ref;
39769         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
39770         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
39771         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
39772         *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);
39773         return tag_ptr(ret_conv, true);
39774 }
39775
39776 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) {
39777         LDKPublicKey per_commitment_point_ref;
39778         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
39779         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
39780         LDKChannelPublicKeys broadcaster_keys_conv;
39781         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
39782         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
39783         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
39784         broadcaster_keys_conv.is_owned = false;
39785         LDKChannelPublicKeys countersignatory_keys_conv;
39786         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
39787         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
39788         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
39789         countersignatory_keys_conv.is_owned = false;
39790         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
39791         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
39792         return tag_ptr(ret_conv, true);
39793 }
39794
39795 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) {
39796         LDKPublicKey revocation_key_ref;
39797         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
39798         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
39799         LDKPublicKey broadcaster_delayed_payment_key_ref;
39800         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
39801         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
39802         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
39803         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39804         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39805         CVec_u8Z_free(ret_var);
39806         return ret_arr;
39807 }
39808
39809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39810         LDKHTLCOutputInCommitment this_obj_conv;
39811         this_obj_conv.inner = untag_ptr(this_obj);
39812         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39814         HTLCOutputInCommitment_free(this_obj_conv);
39815 }
39816
39817 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
39818         LDKHTLCOutputInCommitment this_ptr_conv;
39819         this_ptr_conv.inner = untag_ptr(this_ptr);
39820         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39822         this_ptr_conv.is_owned = false;
39823         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
39824         return ret_conv;
39825 }
39826
39827 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
39828         LDKHTLCOutputInCommitment this_ptr_conv;
39829         this_ptr_conv.inner = untag_ptr(this_ptr);
39830         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39832         this_ptr_conv.is_owned = false;
39833         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
39834 }
39835
39836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
39837         LDKHTLCOutputInCommitment this_ptr_conv;
39838         this_ptr_conv.inner = untag_ptr(this_ptr);
39839         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39841         this_ptr_conv.is_owned = false;
39842         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
39843         return ret_conv;
39844 }
39845
39846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39847         LDKHTLCOutputInCommitment this_ptr_conv;
39848         this_ptr_conv.inner = untag_ptr(this_ptr);
39849         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39851         this_ptr_conv.is_owned = false;
39852         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
39853 }
39854
39855 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
39856         LDKHTLCOutputInCommitment this_ptr_conv;
39857         this_ptr_conv.inner = untag_ptr(this_ptr);
39858         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39860         this_ptr_conv.is_owned = false;
39861         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
39862         return ret_conv;
39863 }
39864
39865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39866         LDKHTLCOutputInCommitment this_ptr_conv;
39867         this_ptr_conv.inner = untag_ptr(this_ptr);
39868         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39870         this_ptr_conv.is_owned = false;
39871         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
39872 }
39873
39874 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39875         LDKHTLCOutputInCommitment this_ptr_conv;
39876         this_ptr_conv.inner = untag_ptr(this_ptr);
39877         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39879         this_ptr_conv.is_owned = false;
39880         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39881         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
39882         return ret_arr;
39883 }
39884
39885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39886         LDKHTLCOutputInCommitment this_ptr_conv;
39887         this_ptr_conv.inner = untag_ptr(this_ptr);
39888         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39890         this_ptr_conv.is_owned = false;
39891         LDKThirtyTwoBytes val_ref;
39892         CHECK((*env)->GetArrayLength(env, val) == 32);
39893         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39894         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
39895 }
39896
39897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
39898         LDKHTLCOutputInCommitment this_ptr_conv;
39899         this_ptr_conv.inner = untag_ptr(this_ptr);
39900         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39902         this_ptr_conv.is_owned = false;
39903         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
39904         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
39905         int64_t ret_ref = tag_ptr(ret_copy, true);
39906         return ret_ref;
39907 }
39908
39909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39910         LDKHTLCOutputInCommitment this_ptr_conv;
39911         this_ptr_conv.inner = untag_ptr(this_ptr);
39912         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39914         this_ptr_conv.is_owned = false;
39915         void* val_ptr = untag_ptr(val);
39916         CHECK_ACCESS(val_ptr);
39917         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
39918         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
39919         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
39920 }
39921
39922 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) {
39923         LDKThirtyTwoBytes payment_hash_arg_ref;
39924         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
39925         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
39926         void* transaction_output_index_arg_ptr = untag_ptr(transaction_output_index_arg);
39927         CHECK_ACCESS(transaction_output_index_arg_ptr);
39928         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
39929         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(transaction_output_index_arg));
39930         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
39931         int64_t ret_ref = 0;
39932         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39933         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39934         return ret_ref;
39935 }
39936
39937 static inline uint64_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
39938         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
39939         int64_t ret_ref = 0;
39940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39941         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39942         return ret_ref;
39943 }
39944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39945         LDKHTLCOutputInCommitment arg_conv;
39946         arg_conv.inner = untag_ptr(arg);
39947         arg_conv.is_owned = ptr_is_owned(arg);
39948         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39949         arg_conv.is_owned = false;
39950         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
39951         return ret_conv;
39952 }
39953
39954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39955         LDKHTLCOutputInCommitment orig_conv;
39956         orig_conv.inner = untag_ptr(orig);
39957         orig_conv.is_owned = ptr_is_owned(orig);
39958         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39959         orig_conv.is_owned = false;
39960         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
39961         int64_t ret_ref = 0;
39962         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39963         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39964         return ret_ref;
39965 }
39966
39967 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
39968         LDKHTLCOutputInCommitment obj_conv;
39969         obj_conv.inner = untag_ptr(obj);
39970         obj_conv.is_owned = ptr_is_owned(obj);
39971         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39972         obj_conv.is_owned = false;
39973         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
39974         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39975         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39976         CVec_u8Z_free(ret_var);
39977         return ret_arr;
39978 }
39979
39980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39981         LDKu8slice ser_ref;
39982         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39983         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39984         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
39985         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
39986         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39987         return tag_ptr(ret_conv, true);
39988 }
39989
39990 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) {
39991         LDKHTLCOutputInCommitment htlc_conv;
39992         htlc_conv.inner = untag_ptr(htlc);
39993         htlc_conv.is_owned = ptr_is_owned(htlc);
39994         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
39995         htlc_conv.is_owned = false;
39996         LDKTxCreationKeys keys_conv;
39997         keys_conv.inner = untag_ptr(keys);
39998         keys_conv.is_owned = ptr_is_owned(keys);
39999         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
40000         keys_conv.is_owned = false;
40001         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
40002         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40003         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40004         CVec_u8Z_free(ret_var);
40005         return ret_arr;
40006 }
40007
40008 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
40009         LDKPublicKey broadcaster_ref;
40010         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
40011         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
40012         LDKPublicKey countersignatory_ref;
40013         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
40014         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
40015         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
40016         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40017         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40018         CVec_u8Z_free(ret_var);
40019         return ret_arr;
40020 }
40021
40022 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) {
40023         unsigned char commitment_txid_arr[32];
40024         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
40025         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
40026         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
40027         LDKHTLCOutputInCommitment htlc_conv;
40028         htlc_conv.inner = untag_ptr(htlc);
40029         htlc_conv.is_owned = ptr_is_owned(htlc);
40030         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
40031         htlc_conv.is_owned = false;
40032         LDKPublicKey broadcaster_delayed_payment_key_ref;
40033         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
40034         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
40035         LDKPublicKey revocation_key_ref;
40036         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
40037         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
40038         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);
40039         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40040         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40041         Transaction_free(ret_var);
40042         return ret_arr;
40043 }
40044
40045 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
40046         LDKPublicKey funding_pubkey_ref;
40047         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
40048         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
40049         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
40050         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40051         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40052         CVec_u8Z_free(ret_var);
40053         return ret_arr;
40054 }
40055
40056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40057         LDKChannelTransactionParameters this_obj_conv;
40058         this_obj_conv.inner = untag_ptr(this_obj);
40059         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40061         ChannelTransactionParameters_free(this_obj_conv);
40062 }
40063
40064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
40065         LDKChannelTransactionParameters this_ptr_conv;
40066         this_ptr_conv.inner = untag_ptr(this_ptr);
40067         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40069         this_ptr_conv.is_owned = false;
40070         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
40071         int64_t ret_ref = 0;
40072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40073         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40074         return ret_ref;
40075 }
40076
40077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40078         LDKChannelTransactionParameters this_ptr_conv;
40079         this_ptr_conv.inner = untag_ptr(this_ptr);
40080         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40082         this_ptr_conv.is_owned = false;
40083         LDKChannelPublicKeys val_conv;
40084         val_conv.inner = untag_ptr(val);
40085         val_conv.is_owned = ptr_is_owned(val);
40086         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40087         val_conv = ChannelPublicKeys_clone(&val_conv);
40088         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
40089 }
40090
40091 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
40092         LDKChannelTransactionParameters this_ptr_conv;
40093         this_ptr_conv.inner = untag_ptr(this_ptr);
40094         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40096         this_ptr_conv.is_owned = false;
40097         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
40098         return ret_conv;
40099 }
40100
40101 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) {
40102         LDKChannelTransactionParameters this_ptr_conv;
40103         this_ptr_conv.inner = untag_ptr(this_ptr);
40104         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40106         this_ptr_conv.is_owned = false;
40107         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
40108 }
40109
40110 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
40111         LDKChannelTransactionParameters this_ptr_conv;
40112         this_ptr_conv.inner = untag_ptr(this_ptr);
40113         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40115         this_ptr_conv.is_owned = false;
40116         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
40117         return ret_conv;
40118 }
40119
40120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
40121         LDKChannelTransactionParameters this_ptr_conv;
40122         this_ptr_conv.inner = untag_ptr(this_ptr);
40123         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40125         this_ptr_conv.is_owned = false;
40126         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
40127 }
40128
40129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
40130         LDKChannelTransactionParameters this_ptr_conv;
40131         this_ptr_conv.inner = untag_ptr(this_ptr);
40132         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40134         this_ptr_conv.is_owned = false;
40135         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
40136         int64_t ret_ref = 0;
40137         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40138         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40139         return ret_ref;
40140 }
40141
40142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40143         LDKChannelTransactionParameters this_ptr_conv;
40144         this_ptr_conv.inner = untag_ptr(this_ptr);
40145         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40147         this_ptr_conv.is_owned = false;
40148         LDKCounterpartyChannelTransactionParameters val_conv;
40149         val_conv.inner = untag_ptr(val);
40150         val_conv.is_owned = ptr_is_owned(val);
40151         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40152         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
40153         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
40154 }
40155
40156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
40157         LDKChannelTransactionParameters this_ptr_conv;
40158         this_ptr_conv.inner = untag_ptr(this_ptr);
40159         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40161         this_ptr_conv.is_owned = false;
40162         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
40163         int64_t ret_ref = 0;
40164         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40165         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40166         return ret_ref;
40167 }
40168
40169 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40170         LDKChannelTransactionParameters this_ptr_conv;
40171         this_ptr_conv.inner = untag_ptr(this_ptr);
40172         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40174         this_ptr_conv.is_owned = false;
40175         LDKOutPoint val_conv;
40176         val_conv.inner = untag_ptr(val);
40177         val_conv.is_owned = ptr_is_owned(val);
40178         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40179         val_conv = OutPoint_clone(&val_conv);
40180         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
40181 }
40182
40183 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
40184         LDKChannelTransactionParameters this_ptr_conv;
40185         this_ptr_conv.inner = untag_ptr(this_ptr);
40186         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40188         this_ptr_conv.is_owned = false;
40189         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
40190         return ret_conv;
40191 }
40192
40193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
40194         LDKChannelTransactionParameters this_ptr_conv;
40195         this_ptr_conv.inner = untag_ptr(this_ptr);
40196         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40198         this_ptr_conv.is_owned = false;
40199         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
40200         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
40201 }
40202
40203 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) {
40204         LDKChannelPublicKeys holder_pubkeys_arg_conv;
40205         holder_pubkeys_arg_conv.inner = untag_ptr(holder_pubkeys_arg);
40206         holder_pubkeys_arg_conv.is_owned = ptr_is_owned(holder_pubkeys_arg);
40207         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
40208         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
40209         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
40210         counterparty_parameters_arg_conv.inner = untag_ptr(counterparty_parameters_arg);
40211         counterparty_parameters_arg_conv.is_owned = ptr_is_owned(counterparty_parameters_arg);
40212         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
40213         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
40214         LDKOutPoint funding_outpoint_arg_conv;
40215         funding_outpoint_arg_conv.inner = untag_ptr(funding_outpoint_arg);
40216         funding_outpoint_arg_conv.is_owned = ptr_is_owned(funding_outpoint_arg);
40217         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
40218         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
40219         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
40220         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);
40221         int64_t ret_ref = 0;
40222         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40223         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40224         return ret_ref;
40225 }
40226
40227 static inline uint64_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
40228         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
40229         int64_t ret_ref = 0;
40230         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40231         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40232         return ret_ref;
40233 }
40234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40235         LDKChannelTransactionParameters arg_conv;
40236         arg_conv.inner = untag_ptr(arg);
40237         arg_conv.is_owned = ptr_is_owned(arg);
40238         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40239         arg_conv.is_owned = false;
40240         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
40241         return ret_conv;
40242 }
40243
40244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40245         LDKChannelTransactionParameters orig_conv;
40246         orig_conv.inner = untag_ptr(orig);
40247         orig_conv.is_owned = ptr_is_owned(orig);
40248         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40249         orig_conv.is_owned = false;
40250         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
40251         int64_t ret_ref = 0;
40252         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40253         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40254         return ret_ref;
40255 }
40256
40257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40258         LDKCounterpartyChannelTransactionParameters this_obj_conv;
40259         this_obj_conv.inner = untag_ptr(this_obj);
40260         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40261         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40262         CounterpartyChannelTransactionParameters_free(this_obj_conv);
40263 }
40264
40265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
40266         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
40267         this_ptr_conv.inner = untag_ptr(this_ptr);
40268         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40270         this_ptr_conv.is_owned = false;
40271         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
40272         int64_t ret_ref = 0;
40273         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40274         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40275         return ret_ref;
40276 }
40277
40278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40279         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
40280         this_ptr_conv.inner = untag_ptr(this_ptr);
40281         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40283         this_ptr_conv.is_owned = false;
40284         LDKChannelPublicKeys val_conv;
40285         val_conv.inner = untag_ptr(val);
40286         val_conv.is_owned = ptr_is_owned(val);
40287         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
40288         val_conv = ChannelPublicKeys_clone(&val_conv);
40289         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
40290 }
40291
40292 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
40293         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
40294         this_ptr_conv.inner = untag_ptr(this_ptr);
40295         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40297         this_ptr_conv.is_owned = false;
40298         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
40299         return ret_conv;
40300 }
40301
40302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
40303         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
40304         this_ptr_conv.inner = untag_ptr(this_ptr);
40305         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40307         this_ptr_conv.is_owned = false;
40308         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
40309 }
40310
40311 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) {
40312         LDKChannelPublicKeys pubkeys_arg_conv;
40313         pubkeys_arg_conv.inner = untag_ptr(pubkeys_arg);
40314         pubkeys_arg_conv.is_owned = ptr_is_owned(pubkeys_arg);
40315         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
40316         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
40317         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
40318         int64_t ret_ref = 0;
40319         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40320         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40321         return ret_ref;
40322 }
40323
40324 static inline uint64_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
40325         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
40326         int64_t ret_ref = 0;
40327         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40328         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40329         return ret_ref;
40330 }
40331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40332         LDKCounterpartyChannelTransactionParameters arg_conv;
40333         arg_conv.inner = untag_ptr(arg);
40334         arg_conv.is_owned = ptr_is_owned(arg);
40335         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40336         arg_conv.is_owned = false;
40337         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
40338         return ret_conv;
40339 }
40340
40341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40342         LDKCounterpartyChannelTransactionParameters orig_conv;
40343         orig_conv.inner = untag_ptr(orig);
40344         orig_conv.is_owned = ptr_is_owned(orig);
40345         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40346         orig_conv.is_owned = false;
40347         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
40348         int64_t ret_ref = 0;
40349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40350         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40351         return ret_ref;
40352 }
40353
40354 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
40355         LDKChannelTransactionParameters this_arg_conv;
40356         this_arg_conv.inner = untag_ptr(this_arg);
40357         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40358         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40359         this_arg_conv.is_owned = false;
40360         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
40361         return ret_conv;
40362 }
40363
40364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
40365         LDKChannelTransactionParameters this_arg_conv;
40366         this_arg_conv.inner = untag_ptr(this_arg);
40367         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40369         this_arg_conv.is_owned = false;
40370         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
40371         int64_t ret_ref = 0;
40372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40373         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40374         return ret_ref;
40375 }
40376
40377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
40378         LDKChannelTransactionParameters this_arg_conv;
40379         this_arg_conv.inner = untag_ptr(this_arg);
40380         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40382         this_arg_conv.is_owned = false;
40383         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
40384         int64_t ret_ref = 0;
40385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40386         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40387         return ret_ref;
40388 }
40389
40390 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
40391         LDKCounterpartyChannelTransactionParameters obj_conv;
40392         obj_conv.inner = untag_ptr(obj);
40393         obj_conv.is_owned = ptr_is_owned(obj);
40394         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40395         obj_conv.is_owned = false;
40396         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
40397         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40398         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40399         CVec_u8Z_free(ret_var);
40400         return ret_arr;
40401 }
40402
40403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40404         LDKu8slice ser_ref;
40405         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40406         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40407         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
40408         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
40409         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40410         return tag_ptr(ret_conv, true);
40411 }
40412
40413 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
40414         LDKChannelTransactionParameters obj_conv;
40415         obj_conv.inner = untag_ptr(obj);
40416         obj_conv.is_owned = ptr_is_owned(obj);
40417         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40418         obj_conv.is_owned = false;
40419         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
40420         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40421         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40422         CVec_u8Z_free(ret_var);
40423         return ret_arr;
40424 }
40425
40426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40427         LDKu8slice ser_ref;
40428         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40429         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40430         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
40431         *ret_conv = ChannelTransactionParameters_read(ser_ref);
40432         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40433         return tag_ptr(ret_conv, true);
40434 }
40435
40436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40437         LDKDirectedChannelTransactionParameters this_obj_conv;
40438         this_obj_conv.inner = untag_ptr(this_obj);
40439         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40441         DirectedChannelTransactionParameters_free(this_obj_conv);
40442 }
40443
40444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
40445         LDKDirectedChannelTransactionParameters this_arg_conv;
40446         this_arg_conv.inner = untag_ptr(this_arg);
40447         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40449         this_arg_conv.is_owned = false;
40450         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
40451         int64_t ret_ref = 0;
40452         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40453         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40454         return ret_ref;
40455 }
40456
40457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
40458         LDKDirectedChannelTransactionParameters this_arg_conv;
40459         this_arg_conv.inner = untag_ptr(this_arg);
40460         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40462         this_arg_conv.is_owned = false;
40463         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
40464         int64_t ret_ref = 0;
40465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40466         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40467         return ret_ref;
40468 }
40469
40470 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
40471         LDKDirectedChannelTransactionParameters this_arg_conv;
40472         this_arg_conv.inner = untag_ptr(this_arg);
40473         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40475         this_arg_conv.is_owned = false;
40476         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
40477         return ret_conv;
40478 }
40479
40480 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
40481         LDKDirectedChannelTransactionParameters this_arg_conv;
40482         this_arg_conv.inner = untag_ptr(this_arg);
40483         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40485         this_arg_conv.is_owned = false;
40486         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
40487         return ret_conv;
40488 }
40489
40490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
40491         LDKDirectedChannelTransactionParameters this_arg_conv;
40492         this_arg_conv.inner = untag_ptr(this_arg);
40493         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40495         this_arg_conv.is_owned = false;
40496         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
40497         int64_t ret_ref = 0;
40498         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40499         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40500         return ret_ref;
40501 }
40502
40503 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
40504         LDKDirectedChannelTransactionParameters this_arg_conv;
40505         this_arg_conv.inner = untag_ptr(this_arg);
40506         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40508         this_arg_conv.is_owned = false;
40509         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
40510         return ret_conv;
40511 }
40512
40513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40514         LDKHolderCommitmentTransaction this_obj_conv;
40515         this_obj_conv.inner = untag_ptr(this_obj);
40516         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40518         HolderCommitmentTransaction_free(this_obj_conv);
40519 }
40520
40521 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
40522         LDKHolderCommitmentTransaction this_ptr_conv;
40523         this_ptr_conv.inner = untag_ptr(this_ptr);
40524         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40526         this_ptr_conv.is_owned = false;
40527         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
40528         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
40529         return ret_arr;
40530 }
40531
40532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40533         LDKHolderCommitmentTransaction this_ptr_conv;
40534         this_ptr_conv.inner = untag_ptr(this_ptr);
40535         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40537         this_ptr_conv.is_owned = false;
40538         LDKSignature val_ref;
40539         CHECK((*env)->GetArrayLength(env, val) == 64);
40540         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
40541         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
40542 }
40543
40544 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr) {
40545         LDKHolderCommitmentTransaction this_ptr_conv;
40546         this_ptr_conv.inner = untag_ptr(this_ptr);
40547         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40549         this_ptr_conv.is_owned = false;
40550         LDKCVec_SignatureZ ret_var = HolderCommitmentTransaction_get_counterparty_htlc_sigs(&this_ptr_conv);
40551         jobjectArray ret_arr = NULL;
40552         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
40553         ;
40554         for (size_t i = 0; i < ret_var.datalen; i++) {
40555                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
40556                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
40557                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
40558         }
40559         
40560         FREE(ret_var.data);
40561         return ret_arr;
40562 }
40563
40564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
40565         LDKHolderCommitmentTransaction this_ptr_conv;
40566         this_ptr_conv.inner = untag_ptr(this_ptr);
40567         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40569         this_ptr_conv.is_owned = false;
40570         LDKCVec_SignatureZ val_constr;
40571         val_constr.datalen = (*env)->GetArrayLength(env, val);
40572         if (val_constr.datalen > 0)
40573                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
40574         else
40575                 val_constr.data = NULL;
40576         for (size_t i = 0; i < val_constr.datalen; i++) {
40577                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
40578                 LDKSignature val_conv_8_ref;
40579                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
40580                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
40581                 val_constr.data[i] = val_conv_8_ref;
40582         }
40583         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
40584 }
40585
40586 static inline uint64_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
40587         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
40588         int64_t ret_ref = 0;
40589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40590         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40591         return ret_ref;
40592 }
40593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40594         LDKHolderCommitmentTransaction arg_conv;
40595         arg_conv.inner = untag_ptr(arg);
40596         arg_conv.is_owned = ptr_is_owned(arg);
40597         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40598         arg_conv.is_owned = false;
40599         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
40600         return ret_conv;
40601 }
40602
40603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40604         LDKHolderCommitmentTransaction orig_conv;
40605         orig_conv.inner = untag_ptr(orig);
40606         orig_conv.is_owned = ptr_is_owned(orig);
40607         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40608         orig_conv.is_owned = false;
40609         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
40610         int64_t ret_ref = 0;
40611         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40612         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40613         return ret_ref;
40614 }
40615
40616 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
40617         LDKHolderCommitmentTransaction obj_conv;
40618         obj_conv.inner = untag_ptr(obj);
40619         obj_conv.is_owned = ptr_is_owned(obj);
40620         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40621         obj_conv.is_owned = false;
40622         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
40623         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40624         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40625         CVec_u8Z_free(ret_var);
40626         return ret_arr;
40627 }
40628
40629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40630         LDKu8slice ser_ref;
40631         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40632         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40633         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
40634         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
40635         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40636         return tag_ptr(ret_conv, true);
40637 }
40638
40639 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) {
40640         LDKCommitmentTransaction commitment_tx_conv;
40641         commitment_tx_conv.inner = untag_ptr(commitment_tx);
40642         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
40643         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
40644         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
40645         LDKSignature counterparty_sig_ref;
40646         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
40647         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
40648         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
40649         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
40650         if (counterparty_htlc_sigs_constr.datalen > 0)
40651                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
40652         else
40653                 counterparty_htlc_sigs_constr.data = NULL;
40654         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
40655                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
40656                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
40657                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
40658                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
40659                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
40660         }
40661         LDKPublicKey holder_funding_key_ref;
40662         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
40663         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
40664         LDKPublicKey counterparty_funding_key_ref;
40665         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
40666         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
40667         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
40668         int64_t ret_ref = 0;
40669         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40670         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40671         return ret_ref;
40672 }
40673
40674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40675         LDKBuiltCommitmentTransaction this_obj_conv;
40676         this_obj_conv.inner = untag_ptr(this_obj);
40677         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40679         BuiltCommitmentTransaction_free(this_obj_conv);
40680 }
40681
40682 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
40683         LDKBuiltCommitmentTransaction this_ptr_conv;
40684         this_ptr_conv.inner = untag_ptr(this_ptr);
40685         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40687         this_ptr_conv.is_owned = false;
40688         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
40689         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40690         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40691         Transaction_free(ret_var);
40692         return ret_arr;
40693 }
40694
40695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40696         LDKBuiltCommitmentTransaction this_ptr_conv;
40697         this_ptr_conv.inner = untag_ptr(this_ptr);
40698         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40700         this_ptr_conv.is_owned = false;
40701         LDKTransaction val_ref;
40702         val_ref.datalen = (*env)->GetArrayLength(env, val);
40703         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
40704         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
40705         val_ref.data_is_owned = true;
40706         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
40707 }
40708
40709 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
40710         LDKBuiltCommitmentTransaction this_ptr_conv;
40711         this_ptr_conv.inner = untag_ptr(this_ptr);
40712         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40714         this_ptr_conv.is_owned = false;
40715         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40716         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
40717         return ret_arr;
40718 }
40719
40720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
40721         LDKBuiltCommitmentTransaction this_ptr_conv;
40722         this_ptr_conv.inner = untag_ptr(this_ptr);
40723         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40725         this_ptr_conv.is_owned = false;
40726         LDKThirtyTwoBytes val_ref;
40727         CHECK((*env)->GetArrayLength(env, val) == 32);
40728         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
40729         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
40730 }
40731
40732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
40733         LDKTransaction transaction_arg_ref;
40734         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
40735         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
40736         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
40737         transaction_arg_ref.data_is_owned = true;
40738         LDKThirtyTwoBytes txid_arg_ref;
40739         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
40740         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
40741         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
40742         int64_t ret_ref = 0;
40743         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40744         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40745         return ret_ref;
40746 }
40747
40748 static inline uint64_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
40749         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
40750         int64_t ret_ref = 0;
40751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40752         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40753         return ret_ref;
40754 }
40755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40756         LDKBuiltCommitmentTransaction arg_conv;
40757         arg_conv.inner = untag_ptr(arg);
40758         arg_conv.is_owned = ptr_is_owned(arg);
40759         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40760         arg_conv.is_owned = false;
40761         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
40762         return ret_conv;
40763 }
40764
40765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40766         LDKBuiltCommitmentTransaction orig_conv;
40767         orig_conv.inner = untag_ptr(orig);
40768         orig_conv.is_owned = ptr_is_owned(orig);
40769         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40770         orig_conv.is_owned = false;
40771         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
40772         int64_t ret_ref = 0;
40773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40774         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40775         return ret_ref;
40776 }
40777
40778 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
40779         LDKBuiltCommitmentTransaction obj_conv;
40780         obj_conv.inner = untag_ptr(obj);
40781         obj_conv.is_owned = ptr_is_owned(obj);
40782         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40783         obj_conv.is_owned = false;
40784         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
40785         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40786         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40787         CVec_u8Z_free(ret_var);
40788         return ret_arr;
40789 }
40790
40791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40792         LDKu8slice ser_ref;
40793         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40794         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40795         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
40796         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
40797         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40798         return tag_ptr(ret_conv, true);
40799 }
40800
40801 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) {
40802         LDKBuiltCommitmentTransaction this_arg_conv;
40803         this_arg_conv.inner = untag_ptr(this_arg);
40804         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40806         this_arg_conv.is_owned = false;
40807         LDKu8slice funding_redeemscript_ref;
40808         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
40809         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
40810         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
40811         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
40812         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
40813         return ret_arr;
40814 }
40815
40816 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) {
40817         LDKBuiltCommitmentTransaction this_arg_conv;
40818         this_arg_conv.inner = untag_ptr(this_arg);
40819         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40821         this_arg_conv.is_owned = false;
40822         unsigned char funding_key_arr[32];
40823         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
40824         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
40825         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
40826         LDKu8slice funding_redeemscript_ref;
40827         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
40828         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
40829         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
40830         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
40831         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
40832         return ret_arr;
40833 }
40834
40835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40836         LDKClosingTransaction this_obj_conv;
40837         this_obj_conv.inner = untag_ptr(this_obj);
40838         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40840         ClosingTransaction_free(this_obj_conv);
40841 }
40842
40843 static inline uint64_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
40844         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
40845         int64_t ret_ref = 0;
40846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40847         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40848         return ret_ref;
40849 }
40850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
40851         LDKClosingTransaction arg_conv;
40852         arg_conv.inner = untag_ptr(arg);
40853         arg_conv.is_owned = ptr_is_owned(arg);
40854         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
40855         arg_conv.is_owned = false;
40856         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
40857         return ret_conv;
40858 }
40859
40860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
40861         LDKClosingTransaction orig_conv;
40862         orig_conv.inner = untag_ptr(orig);
40863         orig_conv.is_owned = ptr_is_owned(orig);
40864         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
40865         orig_conv.is_owned = false;
40866         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
40867         int64_t ret_ref = 0;
40868         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40869         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40870         return ret_ref;
40871 }
40872
40873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
40874         LDKClosingTransaction o_conv;
40875         o_conv.inner = untag_ptr(o);
40876         o_conv.is_owned = ptr_is_owned(o);
40877         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40878         o_conv.is_owned = false;
40879         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
40880         return ret_conv;
40881 }
40882
40883 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) {
40884         LDKCVec_u8Z to_holder_script_ref;
40885         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
40886         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
40887         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
40888         LDKCVec_u8Z to_counterparty_script_ref;
40889         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
40890         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
40891         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
40892         LDKOutPoint funding_outpoint_conv;
40893         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
40894         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
40895         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
40896         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
40897         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
40898         int64_t ret_ref = 0;
40899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40900         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40901         return ret_ref;
40902 }
40903
40904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
40905         LDKClosingTransaction this_arg_conv;
40906         this_arg_conv.inner = untag_ptr(this_arg);
40907         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40909         this_arg_conv.is_owned = false;
40910         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
40911         int64_t ret_ref = 0;
40912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40913         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40914         return ret_ref;
40915 }
40916
40917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
40918         LDKClosingTransaction this_arg_conv;
40919         this_arg_conv.inner = untag_ptr(this_arg);
40920         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40922         this_arg_conv.is_owned = false;
40923         LDKOutPoint funding_outpoint_conv;
40924         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
40925         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
40926         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
40927         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
40928         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
40929         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
40930         return tag_ptr(ret_conv, true);
40931 }
40932
40933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
40934         LDKClosingTransaction this_arg_conv;
40935         this_arg_conv.inner = untag_ptr(this_arg);
40936         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40938         this_arg_conv.is_owned = false;
40939         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
40940         return ret_conv;
40941 }
40942
40943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
40944         LDKClosingTransaction this_arg_conv;
40945         this_arg_conv.inner = untag_ptr(this_arg);
40946         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40948         this_arg_conv.is_owned = false;
40949         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
40950         return ret_conv;
40951 }
40952
40953 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
40954         LDKClosingTransaction this_arg_conv;
40955         this_arg_conv.inner = untag_ptr(this_arg);
40956         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40958         this_arg_conv.is_owned = false;
40959         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
40960         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40961         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40962         return ret_arr;
40963 }
40964
40965 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
40966         LDKClosingTransaction this_arg_conv;
40967         this_arg_conv.inner = untag_ptr(this_arg);
40968         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40970         this_arg_conv.is_owned = false;
40971         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
40972         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40973         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40974         return ret_arr;
40975 }
40976
40977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40978         LDKTrustedClosingTransaction this_obj_conv;
40979         this_obj_conv.inner = untag_ptr(this_obj);
40980         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40982         TrustedClosingTransaction_free(this_obj_conv);
40983 }
40984
40985 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
40986         LDKTrustedClosingTransaction this_arg_conv;
40987         this_arg_conv.inner = untag_ptr(this_arg);
40988         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40990         this_arg_conv.is_owned = false;
40991         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
40992         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40993         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40994         Transaction_free(ret_var);
40995         return ret_arr;
40996 }
40997
40998 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) {
40999         LDKTrustedClosingTransaction this_arg_conv;
41000         this_arg_conv.inner = untag_ptr(this_arg);
41001         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41003         this_arg_conv.is_owned = false;
41004         LDKu8slice funding_redeemscript_ref;
41005         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
41006         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
41007         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
41008         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
41009         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
41010         return ret_arr;
41011 }
41012
41013 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) {
41014         LDKTrustedClosingTransaction this_arg_conv;
41015         this_arg_conv.inner = untag_ptr(this_arg);
41016         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41018         this_arg_conv.is_owned = false;
41019         unsigned char funding_key_arr[32];
41020         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
41021         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
41022         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
41023         LDKu8slice funding_redeemscript_ref;
41024         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
41025         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
41026         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
41027         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
41028         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
41029         return ret_arr;
41030 }
41031
41032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41033         LDKCommitmentTransaction this_obj_conv;
41034         this_obj_conv.inner = untag_ptr(this_obj);
41035         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41037         CommitmentTransaction_free(this_obj_conv);
41038 }
41039
41040 static inline uint64_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
41041         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
41042         int64_t ret_ref = 0;
41043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41044         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41045         return ret_ref;
41046 }
41047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41048         LDKCommitmentTransaction arg_conv;
41049         arg_conv.inner = untag_ptr(arg);
41050         arg_conv.is_owned = ptr_is_owned(arg);
41051         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41052         arg_conv.is_owned = false;
41053         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
41054         return ret_conv;
41055 }
41056
41057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41058         LDKCommitmentTransaction orig_conv;
41059         orig_conv.inner = untag_ptr(orig);
41060         orig_conv.is_owned = ptr_is_owned(orig);
41061         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41062         orig_conv.is_owned = false;
41063         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
41064         int64_t ret_ref = 0;
41065         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41066         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41067         return ret_ref;
41068 }
41069
41070 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
41071         LDKCommitmentTransaction obj_conv;
41072         obj_conv.inner = untag_ptr(obj);
41073         obj_conv.is_owned = ptr_is_owned(obj);
41074         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41075         obj_conv.is_owned = false;
41076         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
41077         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41078         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41079         CVec_u8Z_free(ret_var);
41080         return ret_arr;
41081 }
41082
41083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41084         LDKu8slice ser_ref;
41085         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41086         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41087         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
41088         *ret_conv = CommitmentTransaction_read(ser_ref);
41089         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41090         return tag_ptr(ret_conv, true);
41091 }
41092
41093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
41094         LDKCommitmentTransaction this_arg_conv;
41095         this_arg_conv.inner = untag_ptr(this_arg);
41096         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41098         this_arg_conv.is_owned = false;
41099         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
41100         return ret_conv;
41101 }
41102
41103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
41104         LDKCommitmentTransaction this_arg_conv;
41105         this_arg_conv.inner = untag_ptr(this_arg);
41106         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41108         this_arg_conv.is_owned = false;
41109         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
41110         return ret_conv;
41111 }
41112
41113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
41114         LDKCommitmentTransaction this_arg_conv;
41115         this_arg_conv.inner = untag_ptr(this_arg);
41116         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41118         this_arg_conv.is_owned = false;
41119         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
41120         return ret_conv;
41121 }
41122
41123 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
41124         LDKCommitmentTransaction this_arg_conv;
41125         this_arg_conv.inner = untag_ptr(this_arg);
41126         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41128         this_arg_conv.is_owned = false;
41129         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
41130         return ret_conv;
41131 }
41132
41133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
41134         LDKCommitmentTransaction this_arg_conv;
41135         this_arg_conv.inner = untag_ptr(this_arg);
41136         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41138         this_arg_conv.is_owned = false;
41139         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
41140         int64_t ret_ref = 0;
41141         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41142         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41143         return ret_ref;
41144 }
41145
41146 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) {
41147         LDKCommitmentTransaction this_arg_conv;
41148         this_arg_conv.inner = untag_ptr(this_arg);
41149         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41151         this_arg_conv.is_owned = false;
41152         LDKDirectedChannelTransactionParameters channel_parameters_conv;
41153         channel_parameters_conv.inner = untag_ptr(channel_parameters);
41154         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
41155         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
41156         channel_parameters_conv.is_owned = false;
41157         LDKChannelPublicKeys broadcaster_keys_conv;
41158         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
41159         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
41160         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
41161         broadcaster_keys_conv.is_owned = false;
41162         LDKChannelPublicKeys countersignatory_keys_conv;
41163         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
41164         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
41165         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
41166         countersignatory_keys_conv.is_owned = false;
41167         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
41168         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
41169         return tag_ptr(ret_conv, true);
41170 }
41171
41172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41173         LDKTrustedCommitmentTransaction this_obj_conv;
41174         this_obj_conv.inner = untag_ptr(this_obj);
41175         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41177         TrustedCommitmentTransaction_free(this_obj_conv);
41178 }
41179
41180 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
41181         LDKTrustedCommitmentTransaction this_arg_conv;
41182         this_arg_conv.inner = untag_ptr(this_arg);
41183         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41185         this_arg_conv.is_owned = false;
41186         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
41187         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
41188         return ret_arr;
41189 }
41190
41191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
41192         LDKTrustedCommitmentTransaction this_arg_conv;
41193         this_arg_conv.inner = untag_ptr(this_arg);
41194         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41196         this_arg_conv.is_owned = false;
41197         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
41198         int64_t ret_ref = 0;
41199         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41200         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41201         return ret_ref;
41202 }
41203
41204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
41205         LDKTrustedCommitmentTransaction this_arg_conv;
41206         this_arg_conv.inner = untag_ptr(this_arg);
41207         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41209         this_arg_conv.is_owned = false;
41210         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
41211         int64_t ret_ref = 0;
41212         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41213         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41214         return ret_ref;
41215 }
41216
41217 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
41218         LDKTrustedCommitmentTransaction this_arg_conv;
41219         this_arg_conv.inner = untag_ptr(this_arg);
41220         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41222         this_arg_conv.is_owned = false;
41223         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
41224         return ret_conv;
41225 }
41226
41227 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) {
41228         LDKTrustedCommitmentTransaction this_arg_conv;
41229         this_arg_conv.inner = untag_ptr(this_arg);
41230         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41232         this_arg_conv.is_owned = false;
41233         unsigned char htlc_base_key_arr[32];
41234         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
41235         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
41236         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
41237         LDKDirectedChannelTransactionParameters channel_parameters_conv;
41238         channel_parameters_conv.inner = untag_ptr(channel_parameters);
41239         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
41240         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
41241         channel_parameters_conv.is_owned = false;
41242         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
41243         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
41244         return tag_ptr(ret_conv, true);
41245 }
41246
41247 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) {
41248         LDKPublicKey broadcaster_payment_basepoint_ref;
41249         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
41250         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
41251         LDKPublicKey countersignatory_payment_basepoint_ref;
41252         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
41253         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
41254         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
41255         return ret_conv;
41256 }
41257
41258 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41259         LDKInitFeatures a_conv;
41260         a_conv.inner = untag_ptr(a);
41261         a_conv.is_owned = ptr_is_owned(a);
41262         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41263         a_conv.is_owned = false;
41264         LDKInitFeatures b_conv;
41265         b_conv.inner = untag_ptr(b);
41266         b_conv.is_owned = ptr_is_owned(b);
41267         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41268         b_conv.is_owned = false;
41269         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
41270         return ret_conv;
41271 }
41272
41273 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41274         LDKNodeFeatures a_conv;
41275         a_conv.inner = untag_ptr(a);
41276         a_conv.is_owned = ptr_is_owned(a);
41277         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41278         a_conv.is_owned = false;
41279         LDKNodeFeatures b_conv;
41280         b_conv.inner = untag_ptr(b);
41281         b_conv.is_owned = ptr_is_owned(b);
41282         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41283         b_conv.is_owned = false;
41284         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
41285         return ret_conv;
41286 }
41287
41288 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41289         LDKChannelFeatures a_conv;
41290         a_conv.inner = untag_ptr(a);
41291         a_conv.is_owned = ptr_is_owned(a);
41292         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41293         a_conv.is_owned = false;
41294         LDKChannelFeatures b_conv;
41295         b_conv.inner = untag_ptr(b);
41296         b_conv.is_owned = ptr_is_owned(b);
41297         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41298         b_conv.is_owned = false;
41299         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
41300         return ret_conv;
41301 }
41302
41303 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41304         LDKInvoiceFeatures a_conv;
41305         a_conv.inner = untag_ptr(a);
41306         a_conv.is_owned = ptr_is_owned(a);
41307         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41308         a_conv.is_owned = false;
41309         LDKInvoiceFeatures b_conv;
41310         b_conv.inner = untag_ptr(b);
41311         b_conv.is_owned = ptr_is_owned(b);
41312         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41313         b_conv.is_owned = false;
41314         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
41315         return ret_conv;
41316 }
41317
41318 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41319         LDKChannelTypeFeatures a_conv;
41320         a_conv.inner = untag_ptr(a);
41321         a_conv.is_owned = ptr_is_owned(a);
41322         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41323         a_conv.is_owned = false;
41324         LDKChannelTypeFeatures b_conv;
41325         b_conv.inner = untag_ptr(b);
41326         b_conv.is_owned = ptr_is_owned(b);
41327         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41328         b_conv.is_owned = false;
41329         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
41330         return ret_conv;
41331 }
41332
41333 static inline uint64_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
41334         LDKInitFeatures ret_var = InitFeatures_clone(arg);
41335         int64_t ret_ref = 0;
41336         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41337         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41338         return ret_ref;
41339 }
41340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41341         LDKInitFeatures arg_conv;
41342         arg_conv.inner = untag_ptr(arg);
41343         arg_conv.is_owned = ptr_is_owned(arg);
41344         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41345         arg_conv.is_owned = false;
41346         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
41347         return ret_conv;
41348 }
41349
41350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41351         LDKInitFeatures orig_conv;
41352         orig_conv.inner = untag_ptr(orig);
41353         orig_conv.is_owned = ptr_is_owned(orig);
41354         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41355         orig_conv.is_owned = false;
41356         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
41357         int64_t ret_ref = 0;
41358         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41359         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41360         return ret_ref;
41361 }
41362
41363 static inline uint64_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
41364         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
41365         int64_t ret_ref = 0;
41366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41367         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41368         return ret_ref;
41369 }
41370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41371         LDKNodeFeatures arg_conv;
41372         arg_conv.inner = untag_ptr(arg);
41373         arg_conv.is_owned = ptr_is_owned(arg);
41374         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41375         arg_conv.is_owned = false;
41376         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
41377         return ret_conv;
41378 }
41379
41380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41381         LDKNodeFeatures orig_conv;
41382         orig_conv.inner = untag_ptr(orig);
41383         orig_conv.is_owned = ptr_is_owned(orig);
41384         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41385         orig_conv.is_owned = false;
41386         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
41387         int64_t ret_ref = 0;
41388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41389         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41390         return ret_ref;
41391 }
41392
41393 static inline uint64_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
41394         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
41395         int64_t ret_ref = 0;
41396         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41397         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41398         return ret_ref;
41399 }
41400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41401         LDKChannelFeatures arg_conv;
41402         arg_conv.inner = untag_ptr(arg);
41403         arg_conv.is_owned = ptr_is_owned(arg);
41404         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41405         arg_conv.is_owned = false;
41406         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
41407         return ret_conv;
41408 }
41409
41410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41411         LDKChannelFeatures orig_conv;
41412         orig_conv.inner = untag_ptr(orig);
41413         orig_conv.is_owned = ptr_is_owned(orig);
41414         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41415         orig_conv.is_owned = false;
41416         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
41417         int64_t ret_ref = 0;
41418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41419         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41420         return ret_ref;
41421 }
41422
41423 static inline uint64_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
41424         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
41425         int64_t ret_ref = 0;
41426         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41427         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41428         return ret_ref;
41429 }
41430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41431         LDKInvoiceFeatures arg_conv;
41432         arg_conv.inner = untag_ptr(arg);
41433         arg_conv.is_owned = ptr_is_owned(arg);
41434         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41435         arg_conv.is_owned = false;
41436         int64_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
41437         return ret_conv;
41438 }
41439
41440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41441         LDKInvoiceFeatures orig_conv;
41442         orig_conv.inner = untag_ptr(orig);
41443         orig_conv.is_owned = ptr_is_owned(orig);
41444         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41445         orig_conv.is_owned = false;
41446         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
41447         int64_t ret_ref = 0;
41448         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41449         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41450         return ret_ref;
41451 }
41452
41453 static inline uint64_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
41454         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
41455         int64_t ret_ref = 0;
41456         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41457         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41458         return ret_ref;
41459 }
41460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41461         LDKChannelTypeFeatures arg_conv;
41462         arg_conv.inner = untag_ptr(arg);
41463         arg_conv.is_owned = ptr_is_owned(arg);
41464         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41465         arg_conv.is_owned = false;
41466         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
41467         return ret_conv;
41468 }
41469
41470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41471         LDKChannelTypeFeatures orig_conv;
41472         orig_conv.inner = untag_ptr(orig);
41473         orig_conv.is_owned = ptr_is_owned(orig);
41474         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41475         orig_conv.is_owned = false;
41476         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
41477         int64_t ret_ref = 0;
41478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41479         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41480         return ret_ref;
41481 }
41482
41483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41484         LDKInitFeatures this_obj_conv;
41485         this_obj_conv.inner = untag_ptr(this_obj);
41486         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41488         InitFeatures_free(this_obj_conv);
41489 }
41490
41491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41492         LDKNodeFeatures this_obj_conv;
41493         this_obj_conv.inner = untag_ptr(this_obj);
41494         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41496         NodeFeatures_free(this_obj_conv);
41497 }
41498
41499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41500         LDKChannelFeatures this_obj_conv;
41501         this_obj_conv.inner = untag_ptr(this_obj);
41502         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41504         ChannelFeatures_free(this_obj_conv);
41505 }
41506
41507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41508         LDKInvoiceFeatures this_obj_conv;
41509         this_obj_conv.inner = untag_ptr(this_obj);
41510         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41512         InvoiceFeatures_free(this_obj_conv);
41513 }
41514
41515 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41516         LDKChannelTypeFeatures this_obj_conv;
41517         this_obj_conv.inner = untag_ptr(this_obj);
41518         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41520         ChannelTypeFeatures_free(this_obj_conv);
41521 }
41522
41523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known_1channel_1features(JNIEnv *env, jclass clz) {
41524         LDKInitFeatures ret_var = InitFeatures_known_channel_features();
41525         int64_t ret_ref = 0;
41526         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41527         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41528         return ret_ref;
41529 }
41530
41531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known_1channel_1features(JNIEnv *env, jclass clz) {
41532         LDKNodeFeatures ret_var = NodeFeatures_known_channel_features();
41533         int64_t ret_ref = 0;
41534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41535         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41536         return ret_ref;
41537 }
41538
41539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
41540         LDKInitFeatures ret_var = InitFeatures_empty();
41541         int64_t ret_ref = 0;
41542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41543         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41544         return ret_ref;
41545 }
41546
41547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
41548         LDKInitFeatures ret_var = InitFeatures_known();
41549         int64_t ret_ref = 0;
41550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41551         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41552         return ret_ref;
41553 }
41554
41555 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41556         LDKInitFeatures this_arg_conv;
41557         this_arg_conv.inner = untag_ptr(this_arg);
41558         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41560         this_arg_conv.is_owned = false;
41561         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
41562         return ret_conv;
41563 }
41564
41565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
41566         LDKNodeFeatures ret_var = NodeFeatures_empty();
41567         int64_t ret_ref = 0;
41568         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41569         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41570         return ret_ref;
41571 }
41572
41573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
41574         LDKNodeFeatures ret_var = NodeFeatures_known();
41575         int64_t ret_ref = 0;
41576         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41577         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41578         return ret_ref;
41579 }
41580
41581 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41582         LDKNodeFeatures this_arg_conv;
41583         this_arg_conv.inner = untag_ptr(this_arg);
41584         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41586         this_arg_conv.is_owned = false;
41587         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
41588         return ret_conv;
41589 }
41590
41591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
41592         LDKChannelFeatures ret_var = ChannelFeatures_empty();
41593         int64_t ret_ref = 0;
41594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41595         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41596         return ret_ref;
41597 }
41598
41599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
41600         LDKChannelFeatures ret_var = ChannelFeatures_known();
41601         int64_t ret_ref = 0;
41602         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41603         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41604         return ret_ref;
41605 }
41606
41607 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41608         LDKChannelFeatures this_arg_conv;
41609         this_arg_conv.inner = untag_ptr(this_arg);
41610         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41612         this_arg_conv.is_owned = false;
41613         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
41614         return ret_conv;
41615 }
41616
41617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
41618         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
41619         int64_t ret_ref = 0;
41620         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41621         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41622         return ret_ref;
41623 }
41624
41625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
41626         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
41627         int64_t ret_ref = 0;
41628         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41629         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41630         return ret_ref;
41631 }
41632
41633 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41634         LDKInvoiceFeatures this_arg_conv;
41635         this_arg_conv.inner = untag_ptr(this_arg);
41636         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41638         this_arg_conv.is_owned = false;
41639         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
41640         return ret_conv;
41641 }
41642
41643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
41644         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
41645         int64_t ret_ref = 0;
41646         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41647         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41648         return ret_ref;
41649 }
41650
41651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1known(JNIEnv *env, jclass clz) {
41652         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_known();
41653         int64_t ret_ref = 0;
41654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41655         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41656         return ret_ref;
41657 }
41658
41659 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
41660         LDKChannelTypeFeatures this_arg_conv;
41661         this_arg_conv.inner = untag_ptr(this_arg);
41662         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41664         this_arg_conv.is_owned = false;
41665         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
41666         return ret_conv;
41667 }
41668
41669 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41670         LDKInitFeatures obj_conv;
41671         obj_conv.inner = untag_ptr(obj);
41672         obj_conv.is_owned = ptr_is_owned(obj);
41673         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41674         obj_conv.is_owned = false;
41675         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
41676         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41677         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41678         CVec_u8Z_free(ret_var);
41679         return ret_arr;
41680 }
41681
41682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41683         LDKu8slice ser_ref;
41684         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41685         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41686         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
41687         *ret_conv = InitFeatures_read(ser_ref);
41688         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41689         return tag_ptr(ret_conv, true);
41690 }
41691
41692 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41693         LDKChannelFeatures obj_conv;
41694         obj_conv.inner = untag_ptr(obj);
41695         obj_conv.is_owned = ptr_is_owned(obj);
41696         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41697         obj_conv.is_owned = false;
41698         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
41699         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41700         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41701         CVec_u8Z_free(ret_var);
41702         return ret_arr;
41703 }
41704
41705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41706         LDKu8slice ser_ref;
41707         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41708         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41709         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
41710         *ret_conv = ChannelFeatures_read(ser_ref);
41711         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41712         return tag_ptr(ret_conv, true);
41713 }
41714
41715 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41716         LDKNodeFeatures obj_conv;
41717         obj_conv.inner = untag_ptr(obj);
41718         obj_conv.is_owned = ptr_is_owned(obj);
41719         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41720         obj_conv.is_owned = false;
41721         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
41722         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41723         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41724         CVec_u8Z_free(ret_var);
41725         return ret_arr;
41726 }
41727
41728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41729         LDKu8slice ser_ref;
41730         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41731         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41732         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
41733         *ret_conv = NodeFeatures_read(ser_ref);
41734         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41735         return tag_ptr(ret_conv, true);
41736 }
41737
41738 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41739         LDKInvoiceFeatures obj_conv;
41740         obj_conv.inner = untag_ptr(obj);
41741         obj_conv.is_owned = ptr_is_owned(obj);
41742         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41743         obj_conv.is_owned = false;
41744         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
41745         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41746         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41747         CVec_u8Z_free(ret_var);
41748         return ret_arr;
41749 }
41750
41751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41752         LDKu8slice ser_ref;
41753         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41754         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41755         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
41756         *ret_conv = InvoiceFeatures_read(ser_ref);
41757         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41758         return tag_ptr(ret_conv, true);
41759 }
41760
41761 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
41762         LDKChannelTypeFeatures obj_conv;
41763         obj_conv.inner = untag_ptr(obj);
41764         obj_conv.is_owned = ptr_is_owned(obj);
41765         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41766         obj_conv.is_owned = false;
41767         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
41768         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41769         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41770         CVec_u8Z_free(ret_var);
41771         return ret_arr;
41772 }
41773
41774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41775         LDKu8slice ser_ref;
41776         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41777         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41778         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
41779         *ret_conv = ChannelTypeFeatures_read(ser_ref);
41780         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41781         return tag_ptr(ret_conv, true);
41782 }
41783
41784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41785         LDKInitFeatures this_arg_conv;
41786         this_arg_conv.inner = untag_ptr(this_arg);
41787         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41789         this_arg_conv.is_owned = false;
41790         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
41791 }
41792
41793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41794         LDKInitFeatures this_arg_conv;
41795         this_arg_conv.inner = untag_ptr(this_arg);
41796         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41798         this_arg_conv.is_owned = false;
41799         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
41800 }
41801
41802 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
41803         LDKInitFeatures this_arg_conv;
41804         this_arg_conv.inner = untag_ptr(this_arg);
41805         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41807         this_arg_conv.is_owned = false;
41808         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
41809         return ret_conv;
41810 }
41811
41812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41813         LDKNodeFeatures this_arg_conv;
41814         this_arg_conv.inner = untag_ptr(this_arg);
41815         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41817         this_arg_conv.is_owned = false;
41818         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
41819 }
41820
41821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41822         LDKNodeFeatures this_arg_conv;
41823         this_arg_conv.inner = untag_ptr(this_arg);
41824         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41826         this_arg_conv.is_owned = false;
41827         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
41828 }
41829
41830 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
41831         LDKNodeFeatures this_arg_conv;
41832         this_arg_conv.inner = untag_ptr(this_arg);
41833         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41835         this_arg_conv.is_owned = false;
41836         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
41837         return ret_conv;
41838 }
41839
41840 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
41841         LDKInitFeatures this_arg_conv;
41842         this_arg_conv.inner = untag_ptr(this_arg);
41843         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41845         this_arg_conv.is_owned = false;
41846         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
41847         return ret_conv;
41848 }
41849
41850 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
41851         LDKNodeFeatures this_arg_conv;
41852         this_arg_conv.inner = untag_ptr(this_arg);
41853         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41855         this_arg_conv.is_owned = false;
41856         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
41857         return ret_conv;
41858 }
41859
41860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41861         LDKInitFeatures this_arg_conv;
41862         this_arg_conv.inner = untag_ptr(this_arg);
41863         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41865         this_arg_conv.is_owned = false;
41866         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
41867 }
41868
41869 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41870         LDKInitFeatures this_arg_conv;
41871         this_arg_conv.inner = untag_ptr(this_arg);
41872         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41874         this_arg_conv.is_owned = false;
41875         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
41876 }
41877
41878 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1initial_1routing_1sync(JNIEnv *env, jclass clz, int64_t this_arg) {
41879         LDKInitFeatures this_arg_conv;
41880         this_arg_conv.inner = untag_ptr(this_arg);
41881         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41883         this_arg_conv.is_owned = false;
41884         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
41885         return ret_conv;
41886 }
41887
41888 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41889         LDKInitFeatures this_arg_conv;
41890         this_arg_conv.inner = untag_ptr(this_arg);
41891         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41893         this_arg_conv.is_owned = false;
41894         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
41895 }
41896
41897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41898         LDKInitFeatures this_arg_conv;
41899         this_arg_conv.inner = untag_ptr(this_arg);
41900         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41902         this_arg_conv.is_owned = false;
41903         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
41904 }
41905
41906 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
41907         LDKInitFeatures this_arg_conv;
41908         this_arg_conv.inner = untag_ptr(this_arg);
41909         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41911         this_arg_conv.is_owned = false;
41912         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
41913         return ret_conv;
41914 }
41915
41916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41917         LDKNodeFeatures this_arg_conv;
41918         this_arg_conv.inner = untag_ptr(this_arg);
41919         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41921         this_arg_conv.is_owned = false;
41922         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
41923 }
41924
41925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41926         LDKNodeFeatures this_arg_conv;
41927         this_arg_conv.inner = untag_ptr(this_arg);
41928         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41930         this_arg_conv.is_owned = false;
41931         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
41932 }
41933
41934 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
41935         LDKNodeFeatures this_arg_conv;
41936         this_arg_conv.inner = untag_ptr(this_arg);
41937         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41939         this_arg_conv.is_owned = false;
41940         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
41941         return ret_conv;
41942 }
41943
41944 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
41945         LDKInitFeatures this_arg_conv;
41946         this_arg_conv.inner = untag_ptr(this_arg);
41947         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41949         this_arg_conv.is_owned = false;
41950         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
41951         return ret_conv;
41952 }
41953
41954 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
41955         LDKNodeFeatures this_arg_conv;
41956         this_arg_conv.inner = untag_ptr(this_arg);
41957         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41959         this_arg_conv.is_owned = false;
41960         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
41961         return ret_conv;
41962 }
41963
41964 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41965         LDKInitFeatures this_arg_conv;
41966         this_arg_conv.inner = untag_ptr(this_arg);
41967         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41969         this_arg_conv.is_owned = false;
41970         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
41971 }
41972
41973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
41974         LDKInitFeatures this_arg_conv;
41975         this_arg_conv.inner = untag_ptr(this_arg);
41976         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41978         this_arg_conv.is_owned = false;
41979         InitFeatures_set_gossip_queries_required(&this_arg_conv);
41980 }
41981
41982 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
41983         LDKInitFeatures this_arg_conv;
41984         this_arg_conv.inner = untag_ptr(this_arg);
41985         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41987         this_arg_conv.is_owned = false;
41988         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
41989         return ret_conv;
41990 }
41991
41992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
41993         LDKNodeFeatures this_arg_conv;
41994         this_arg_conv.inner = untag_ptr(this_arg);
41995         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41997         this_arg_conv.is_owned = false;
41998         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
41999 }
42000
42001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42002         LDKNodeFeatures this_arg_conv;
42003         this_arg_conv.inner = untag_ptr(this_arg);
42004         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42006         this_arg_conv.is_owned = false;
42007         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
42008 }
42009
42010 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
42011         LDKNodeFeatures this_arg_conv;
42012         this_arg_conv.inner = untag_ptr(this_arg);
42013         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42015         this_arg_conv.is_owned = false;
42016         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
42017         return ret_conv;
42018 }
42019
42020 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
42021         LDKInitFeatures this_arg_conv;
42022         this_arg_conv.inner = untag_ptr(this_arg);
42023         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42025         this_arg_conv.is_owned = false;
42026         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
42027         return ret_conv;
42028 }
42029
42030 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
42031         LDKNodeFeatures this_arg_conv;
42032         this_arg_conv.inner = untag_ptr(this_arg);
42033         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42035         this_arg_conv.is_owned = false;
42036         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
42037         return ret_conv;
42038 }
42039
42040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42041         LDKInitFeatures this_arg_conv;
42042         this_arg_conv.inner = untag_ptr(this_arg);
42043         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42045         this_arg_conv.is_owned = false;
42046         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
42047 }
42048
42049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42050         LDKInitFeatures this_arg_conv;
42051         this_arg_conv.inner = untag_ptr(this_arg);
42052         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42054         this_arg_conv.is_owned = false;
42055         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
42056 }
42057
42058 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
42059         LDKInitFeatures this_arg_conv;
42060         this_arg_conv.inner = untag_ptr(this_arg);
42061         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42063         this_arg_conv.is_owned = false;
42064         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
42065         return ret_conv;
42066 }
42067
42068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42069         LDKNodeFeatures this_arg_conv;
42070         this_arg_conv.inner = untag_ptr(this_arg);
42071         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42073         this_arg_conv.is_owned = false;
42074         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
42075 }
42076
42077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42078         LDKNodeFeatures this_arg_conv;
42079         this_arg_conv.inner = untag_ptr(this_arg);
42080         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42082         this_arg_conv.is_owned = false;
42083         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
42084 }
42085
42086 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
42087         LDKNodeFeatures this_arg_conv;
42088         this_arg_conv.inner = untag_ptr(this_arg);
42089         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42091         this_arg_conv.is_owned = false;
42092         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
42093         return ret_conv;
42094 }
42095
42096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42097         LDKInvoiceFeatures this_arg_conv;
42098         this_arg_conv.inner = untag_ptr(this_arg);
42099         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42101         this_arg_conv.is_owned = false;
42102         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
42103 }
42104
42105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42106         LDKInvoiceFeatures this_arg_conv;
42107         this_arg_conv.inner = untag_ptr(this_arg);
42108         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42110         this_arg_conv.is_owned = false;
42111         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
42112 }
42113
42114 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
42115         LDKInvoiceFeatures this_arg_conv;
42116         this_arg_conv.inner = untag_ptr(this_arg);
42117         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42119         this_arg_conv.is_owned = false;
42120         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
42121         return ret_conv;
42122 }
42123
42124 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
42125         LDKInitFeatures this_arg_conv;
42126         this_arg_conv.inner = untag_ptr(this_arg);
42127         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42129         this_arg_conv.is_owned = false;
42130         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
42131         return ret_conv;
42132 }
42133
42134 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
42135         LDKNodeFeatures this_arg_conv;
42136         this_arg_conv.inner = untag_ptr(this_arg);
42137         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42139         this_arg_conv.is_owned = false;
42140         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
42141         return ret_conv;
42142 }
42143
42144 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
42145         LDKInvoiceFeatures this_arg_conv;
42146         this_arg_conv.inner = untag_ptr(this_arg);
42147         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42149         this_arg_conv.is_owned = false;
42150         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
42151         return ret_conv;
42152 }
42153
42154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42155         LDKInitFeatures this_arg_conv;
42156         this_arg_conv.inner = untag_ptr(this_arg);
42157         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42159         this_arg_conv.is_owned = false;
42160         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
42161 }
42162
42163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42164         LDKInitFeatures this_arg_conv;
42165         this_arg_conv.inner = untag_ptr(this_arg);
42166         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42168         this_arg_conv.is_owned = false;
42169         InitFeatures_set_static_remote_key_required(&this_arg_conv);
42170 }
42171
42172 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
42173         LDKInitFeatures this_arg_conv;
42174         this_arg_conv.inner = untag_ptr(this_arg);
42175         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42177         this_arg_conv.is_owned = false;
42178         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
42179         return ret_conv;
42180 }
42181
42182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42183         LDKNodeFeatures this_arg_conv;
42184         this_arg_conv.inner = untag_ptr(this_arg);
42185         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42187         this_arg_conv.is_owned = false;
42188         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
42189 }
42190
42191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42192         LDKNodeFeatures this_arg_conv;
42193         this_arg_conv.inner = untag_ptr(this_arg);
42194         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42196         this_arg_conv.is_owned = false;
42197         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
42198 }
42199
42200 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
42201         LDKNodeFeatures this_arg_conv;
42202         this_arg_conv.inner = untag_ptr(this_arg);
42203         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42205         this_arg_conv.is_owned = false;
42206         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
42207         return ret_conv;
42208 }
42209
42210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42211         LDKChannelTypeFeatures this_arg_conv;
42212         this_arg_conv.inner = untag_ptr(this_arg);
42213         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42214         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42215         this_arg_conv.is_owned = false;
42216         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
42217 }
42218
42219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42220         LDKChannelTypeFeatures this_arg_conv;
42221         this_arg_conv.inner = untag_ptr(this_arg);
42222         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42224         this_arg_conv.is_owned = false;
42225         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
42226 }
42227
42228 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
42229         LDKChannelTypeFeatures this_arg_conv;
42230         this_arg_conv.inner = untag_ptr(this_arg);
42231         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42233         this_arg_conv.is_owned = false;
42234         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
42235         return ret_conv;
42236 }
42237
42238 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
42239         LDKInitFeatures this_arg_conv;
42240         this_arg_conv.inner = untag_ptr(this_arg);
42241         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42243         this_arg_conv.is_owned = false;
42244         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
42245         return ret_conv;
42246 }
42247
42248 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
42249         LDKNodeFeatures this_arg_conv;
42250         this_arg_conv.inner = untag_ptr(this_arg);
42251         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42253         this_arg_conv.is_owned = false;
42254         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
42255         return ret_conv;
42256 }
42257
42258 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
42259         LDKChannelTypeFeatures this_arg_conv;
42260         this_arg_conv.inner = untag_ptr(this_arg);
42261         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42263         this_arg_conv.is_owned = false;
42264         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
42265         return ret_conv;
42266 }
42267
42268 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42269         LDKInitFeatures this_arg_conv;
42270         this_arg_conv.inner = untag_ptr(this_arg);
42271         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42272         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42273         this_arg_conv.is_owned = false;
42274         InitFeatures_set_payment_secret_optional(&this_arg_conv);
42275 }
42276
42277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42278         LDKInitFeatures this_arg_conv;
42279         this_arg_conv.inner = untag_ptr(this_arg);
42280         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42282         this_arg_conv.is_owned = false;
42283         InitFeatures_set_payment_secret_required(&this_arg_conv);
42284 }
42285
42286 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
42287         LDKInitFeatures this_arg_conv;
42288         this_arg_conv.inner = untag_ptr(this_arg);
42289         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42291         this_arg_conv.is_owned = false;
42292         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
42293         return ret_conv;
42294 }
42295
42296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42297         LDKNodeFeatures this_arg_conv;
42298         this_arg_conv.inner = untag_ptr(this_arg);
42299         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42301         this_arg_conv.is_owned = false;
42302         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
42303 }
42304
42305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42306         LDKNodeFeatures this_arg_conv;
42307         this_arg_conv.inner = untag_ptr(this_arg);
42308         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42310         this_arg_conv.is_owned = false;
42311         NodeFeatures_set_payment_secret_required(&this_arg_conv);
42312 }
42313
42314 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
42315         LDKNodeFeatures this_arg_conv;
42316         this_arg_conv.inner = untag_ptr(this_arg);
42317         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42319         this_arg_conv.is_owned = false;
42320         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
42321         return ret_conv;
42322 }
42323
42324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42325         LDKInvoiceFeatures this_arg_conv;
42326         this_arg_conv.inner = untag_ptr(this_arg);
42327         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42329         this_arg_conv.is_owned = false;
42330         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
42331 }
42332
42333 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42334         LDKInvoiceFeatures this_arg_conv;
42335         this_arg_conv.inner = untag_ptr(this_arg);
42336         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42338         this_arg_conv.is_owned = false;
42339         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
42340 }
42341
42342 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
42343         LDKInvoiceFeatures this_arg_conv;
42344         this_arg_conv.inner = untag_ptr(this_arg);
42345         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42347         this_arg_conv.is_owned = false;
42348         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
42349         return ret_conv;
42350 }
42351
42352 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
42353         LDKInitFeatures this_arg_conv;
42354         this_arg_conv.inner = untag_ptr(this_arg);
42355         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42357         this_arg_conv.is_owned = false;
42358         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
42359         return ret_conv;
42360 }
42361
42362 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
42363         LDKNodeFeatures this_arg_conv;
42364         this_arg_conv.inner = untag_ptr(this_arg);
42365         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42367         this_arg_conv.is_owned = false;
42368         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
42369         return ret_conv;
42370 }
42371
42372 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
42373         LDKInvoiceFeatures this_arg_conv;
42374         this_arg_conv.inner = untag_ptr(this_arg);
42375         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42377         this_arg_conv.is_owned = false;
42378         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
42379         return ret_conv;
42380 }
42381
42382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42383         LDKInitFeatures this_arg_conv;
42384         this_arg_conv.inner = untag_ptr(this_arg);
42385         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42387         this_arg_conv.is_owned = false;
42388         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
42389 }
42390
42391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42392         LDKInitFeatures this_arg_conv;
42393         this_arg_conv.inner = untag_ptr(this_arg);
42394         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42396         this_arg_conv.is_owned = false;
42397         InitFeatures_set_basic_mpp_required(&this_arg_conv);
42398 }
42399
42400 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
42401         LDKInitFeatures this_arg_conv;
42402         this_arg_conv.inner = untag_ptr(this_arg);
42403         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42405         this_arg_conv.is_owned = false;
42406         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
42407         return ret_conv;
42408 }
42409
42410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42411         LDKNodeFeatures this_arg_conv;
42412         this_arg_conv.inner = untag_ptr(this_arg);
42413         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42415         this_arg_conv.is_owned = false;
42416         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
42417 }
42418
42419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42420         LDKNodeFeatures this_arg_conv;
42421         this_arg_conv.inner = untag_ptr(this_arg);
42422         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42423         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42424         this_arg_conv.is_owned = false;
42425         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
42426 }
42427
42428 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
42429         LDKNodeFeatures this_arg_conv;
42430         this_arg_conv.inner = untag_ptr(this_arg);
42431         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42433         this_arg_conv.is_owned = false;
42434         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
42435         return ret_conv;
42436 }
42437
42438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42439         LDKInvoiceFeatures this_arg_conv;
42440         this_arg_conv.inner = untag_ptr(this_arg);
42441         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42443         this_arg_conv.is_owned = false;
42444         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
42445 }
42446
42447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42448         LDKInvoiceFeatures this_arg_conv;
42449         this_arg_conv.inner = untag_ptr(this_arg);
42450         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42452         this_arg_conv.is_owned = false;
42453         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
42454 }
42455
42456 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
42457         LDKInvoiceFeatures this_arg_conv;
42458         this_arg_conv.inner = untag_ptr(this_arg);
42459         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42461         this_arg_conv.is_owned = false;
42462         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
42463         return ret_conv;
42464 }
42465
42466 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
42467         LDKInitFeatures this_arg_conv;
42468         this_arg_conv.inner = untag_ptr(this_arg);
42469         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42471         this_arg_conv.is_owned = false;
42472         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
42473         return ret_conv;
42474 }
42475
42476 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
42477         LDKNodeFeatures this_arg_conv;
42478         this_arg_conv.inner = untag_ptr(this_arg);
42479         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42481         this_arg_conv.is_owned = false;
42482         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
42483         return ret_conv;
42484 }
42485
42486 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
42487         LDKInvoiceFeatures this_arg_conv;
42488         this_arg_conv.inner = untag_ptr(this_arg);
42489         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42491         this_arg_conv.is_owned = false;
42492         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
42493         return ret_conv;
42494 }
42495
42496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42497         LDKInitFeatures this_arg_conv;
42498         this_arg_conv.inner = untag_ptr(this_arg);
42499         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42501         this_arg_conv.is_owned = false;
42502         InitFeatures_set_wumbo_optional(&this_arg_conv);
42503 }
42504
42505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42506         LDKInitFeatures this_arg_conv;
42507         this_arg_conv.inner = untag_ptr(this_arg);
42508         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42510         this_arg_conv.is_owned = false;
42511         InitFeatures_set_wumbo_required(&this_arg_conv);
42512 }
42513
42514 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
42515         LDKInitFeatures this_arg_conv;
42516         this_arg_conv.inner = untag_ptr(this_arg);
42517         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42519         this_arg_conv.is_owned = false;
42520         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
42521         return ret_conv;
42522 }
42523
42524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42525         LDKNodeFeatures this_arg_conv;
42526         this_arg_conv.inner = untag_ptr(this_arg);
42527         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42529         this_arg_conv.is_owned = false;
42530         NodeFeatures_set_wumbo_optional(&this_arg_conv);
42531 }
42532
42533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42534         LDKNodeFeatures this_arg_conv;
42535         this_arg_conv.inner = untag_ptr(this_arg);
42536         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42538         this_arg_conv.is_owned = false;
42539         NodeFeatures_set_wumbo_required(&this_arg_conv);
42540 }
42541
42542 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
42543         LDKNodeFeatures this_arg_conv;
42544         this_arg_conv.inner = untag_ptr(this_arg);
42545         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42547         this_arg_conv.is_owned = false;
42548         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
42549         return ret_conv;
42550 }
42551
42552 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
42553         LDKInitFeatures this_arg_conv;
42554         this_arg_conv.inner = untag_ptr(this_arg);
42555         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42557         this_arg_conv.is_owned = false;
42558         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
42559         return ret_conv;
42560 }
42561
42562 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
42563         LDKNodeFeatures this_arg_conv;
42564         this_arg_conv.inner = untag_ptr(this_arg);
42565         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42567         this_arg_conv.is_owned = false;
42568         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
42569         return ret_conv;
42570 }
42571
42572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42573         LDKInitFeatures this_arg_conv;
42574         this_arg_conv.inner = untag_ptr(this_arg);
42575         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42577         this_arg_conv.is_owned = false;
42578         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
42579 }
42580
42581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42582         LDKInitFeatures this_arg_conv;
42583         this_arg_conv.inner = untag_ptr(this_arg);
42584         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42586         this_arg_conv.is_owned = false;
42587         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
42588 }
42589
42590 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
42591         LDKInitFeatures this_arg_conv;
42592         this_arg_conv.inner = untag_ptr(this_arg);
42593         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42595         this_arg_conv.is_owned = false;
42596         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
42597         return ret_conv;
42598 }
42599
42600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42601         LDKNodeFeatures this_arg_conv;
42602         this_arg_conv.inner = untag_ptr(this_arg);
42603         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42605         this_arg_conv.is_owned = false;
42606         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
42607 }
42608
42609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42610         LDKNodeFeatures this_arg_conv;
42611         this_arg_conv.inner = untag_ptr(this_arg);
42612         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42614         this_arg_conv.is_owned = false;
42615         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
42616 }
42617
42618 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
42619         LDKNodeFeatures this_arg_conv;
42620         this_arg_conv.inner = untag_ptr(this_arg);
42621         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42623         this_arg_conv.is_owned = false;
42624         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
42625         return ret_conv;
42626 }
42627
42628 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
42629         LDKInitFeatures this_arg_conv;
42630         this_arg_conv.inner = untag_ptr(this_arg);
42631         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42633         this_arg_conv.is_owned = false;
42634         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
42635         return ret_conv;
42636 }
42637
42638 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
42639         LDKNodeFeatures this_arg_conv;
42640         this_arg_conv.inner = untag_ptr(this_arg);
42641         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42643         this_arg_conv.is_owned = false;
42644         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
42645         return ret_conv;
42646 }
42647
42648 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1onion_1messages_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42649         LDKInitFeatures this_arg_conv;
42650         this_arg_conv.inner = untag_ptr(this_arg);
42651         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42653         this_arg_conv.is_owned = false;
42654         InitFeatures_set_onion_messages_optional(&this_arg_conv);
42655 }
42656
42657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1onion_1messages_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42658         LDKInitFeatures this_arg_conv;
42659         this_arg_conv.inner = untag_ptr(this_arg);
42660         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42662         this_arg_conv.is_owned = false;
42663         InitFeatures_set_onion_messages_required(&this_arg_conv);
42664 }
42665
42666 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
42667         LDKInitFeatures this_arg_conv;
42668         this_arg_conv.inner = untag_ptr(this_arg);
42669         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42671         this_arg_conv.is_owned = false;
42672         jboolean ret_conv = InitFeatures_supports_onion_messages(&this_arg_conv);
42673         return ret_conv;
42674 }
42675
42676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1onion_1messages_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42677         LDKNodeFeatures this_arg_conv;
42678         this_arg_conv.inner = untag_ptr(this_arg);
42679         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42681         this_arg_conv.is_owned = false;
42682         NodeFeatures_set_onion_messages_optional(&this_arg_conv);
42683 }
42684
42685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1onion_1messages_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42686         LDKNodeFeatures this_arg_conv;
42687         this_arg_conv.inner = untag_ptr(this_arg);
42688         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42690         this_arg_conv.is_owned = false;
42691         NodeFeatures_set_onion_messages_required(&this_arg_conv);
42692 }
42693
42694 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
42695         LDKNodeFeatures this_arg_conv;
42696         this_arg_conv.inner = untag_ptr(this_arg);
42697         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42699         this_arg_conv.is_owned = false;
42700         jboolean ret_conv = NodeFeatures_supports_onion_messages(&this_arg_conv);
42701         return ret_conv;
42702 }
42703
42704 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
42705         LDKInitFeatures this_arg_conv;
42706         this_arg_conv.inner = untag_ptr(this_arg);
42707         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42709         this_arg_conv.is_owned = false;
42710         jboolean ret_conv = InitFeatures_requires_onion_messages(&this_arg_conv);
42711         return ret_conv;
42712 }
42713
42714 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
42715         LDKNodeFeatures this_arg_conv;
42716         this_arg_conv.inner = untag_ptr(this_arg);
42717         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42719         this_arg_conv.is_owned = false;
42720         jboolean ret_conv = NodeFeatures_requires_onion_messages(&this_arg_conv);
42721         return ret_conv;
42722 }
42723
42724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42725         LDKInitFeatures this_arg_conv;
42726         this_arg_conv.inner = untag_ptr(this_arg);
42727         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42729         this_arg_conv.is_owned = false;
42730         InitFeatures_set_channel_type_optional(&this_arg_conv);
42731 }
42732
42733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42734         LDKInitFeatures this_arg_conv;
42735         this_arg_conv.inner = untag_ptr(this_arg);
42736         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42738         this_arg_conv.is_owned = false;
42739         InitFeatures_set_channel_type_required(&this_arg_conv);
42740 }
42741
42742 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
42743         LDKInitFeatures this_arg_conv;
42744         this_arg_conv.inner = untag_ptr(this_arg);
42745         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42747         this_arg_conv.is_owned = false;
42748         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
42749         return ret_conv;
42750 }
42751
42752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42753         LDKNodeFeatures this_arg_conv;
42754         this_arg_conv.inner = untag_ptr(this_arg);
42755         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42757         this_arg_conv.is_owned = false;
42758         NodeFeatures_set_channel_type_optional(&this_arg_conv);
42759 }
42760
42761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42762         LDKNodeFeatures this_arg_conv;
42763         this_arg_conv.inner = untag_ptr(this_arg);
42764         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42766         this_arg_conv.is_owned = false;
42767         NodeFeatures_set_channel_type_required(&this_arg_conv);
42768 }
42769
42770 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
42771         LDKNodeFeatures this_arg_conv;
42772         this_arg_conv.inner = untag_ptr(this_arg);
42773         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42775         this_arg_conv.is_owned = false;
42776         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
42777         return ret_conv;
42778 }
42779
42780 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
42781         LDKInitFeatures this_arg_conv;
42782         this_arg_conv.inner = untag_ptr(this_arg);
42783         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42785         this_arg_conv.is_owned = false;
42786         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
42787         return ret_conv;
42788 }
42789
42790 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
42791         LDKNodeFeatures this_arg_conv;
42792         this_arg_conv.inner = untag_ptr(this_arg);
42793         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42795         this_arg_conv.is_owned = false;
42796         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
42797         return ret_conv;
42798 }
42799
42800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42801         LDKInitFeatures this_arg_conv;
42802         this_arg_conv.inner = untag_ptr(this_arg);
42803         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42805         this_arg_conv.is_owned = false;
42806         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
42807 }
42808
42809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42810         LDKInitFeatures this_arg_conv;
42811         this_arg_conv.inner = untag_ptr(this_arg);
42812         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42814         this_arg_conv.is_owned = false;
42815         InitFeatures_set_scid_privacy_required(&this_arg_conv);
42816 }
42817
42818 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42819         LDKInitFeatures this_arg_conv;
42820         this_arg_conv.inner = untag_ptr(this_arg);
42821         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42823         this_arg_conv.is_owned = false;
42824         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
42825         return ret_conv;
42826 }
42827
42828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42829         LDKNodeFeatures this_arg_conv;
42830         this_arg_conv.inner = untag_ptr(this_arg);
42831         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42833         this_arg_conv.is_owned = false;
42834         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
42835 }
42836
42837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42838         LDKNodeFeatures this_arg_conv;
42839         this_arg_conv.inner = untag_ptr(this_arg);
42840         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42842         this_arg_conv.is_owned = false;
42843         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
42844 }
42845
42846 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42847         LDKNodeFeatures this_arg_conv;
42848         this_arg_conv.inner = untag_ptr(this_arg);
42849         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42851         this_arg_conv.is_owned = false;
42852         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
42853         return ret_conv;
42854 }
42855
42856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42857         LDKChannelTypeFeatures this_arg_conv;
42858         this_arg_conv.inner = untag_ptr(this_arg);
42859         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42861         this_arg_conv.is_owned = false;
42862         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
42863 }
42864
42865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42866         LDKChannelTypeFeatures this_arg_conv;
42867         this_arg_conv.inner = untag_ptr(this_arg);
42868         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42870         this_arg_conv.is_owned = false;
42871         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
42872 }
42873
42874 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42875         LDKChannelTypeFeatures this_arg_conv;
42876         this_arg_conv.inner = untag_ptr(this_arg);
42877         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42879         this_arg_conv.is_owned = false;
42880         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
42881         return ret_conv;
42882 }
42883
42884 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42885         LDKInitFeatures this_arg_conv;
42886         this_arg_conv.inner = untag_ptr(this_arg);
42887         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42889         this_arg_conv.is_owned = false;
42890         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
42891         return ret_conv;
42892 }
42893
42894 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42895         LDKNodeFeatures this_arg_conv;
42896         this_arg_conv.inner = untag_ptr(this_arg);
42897         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42899         this_arg_conv.is_owned = false;
42900         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
42901         return ret_conv;
42902 }
42903
42904 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
42905         LDKChannelTypeFeatures this_arg_conv;
42906         this_arg_conv.inner = untag_ptr(this_arg);
42907         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42909         this_arg_conv.is_owned = false;
42910         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
42911         return ret_conv;
42912 }
42913
42914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42915         LDKInitFeatures this_arg_conv;
42916         this_arg_conv.inner = untag_ptr(this_arg);
42917         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42919         this_arg_conv.is_owned = false;
42920         InitFeatures_set_zero_conf_optional(&this_arg_conv);
42921 }
42922
42923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42924         LDKInitFeatures this_arg_conv;
42925         this_arg_conv.inner = untag_ptr(this_arg);
42926         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42928         this_arg_conv.is_owned = false;
42929         InitFeatures_set_zero_conf_required(&this_arg_conv);
42930 }
42931
42932 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42933         LDKInitFeatures this_arg_conv;
42934         this_arg_conv.inner = untag_ptr(this_arg);
42935         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42937         this_arg_conv.is_owned = false;
42938         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
42939         return ret_conv;
42940 }
42941
42942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42943         LDKNodeFeatures this_arg_conv;
42944         this_arg_conv.inner = untag_ptr(this_arg);
42945         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42947         this_arg_conv.is_owned = false;
42948         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
42949 }
42950
42951 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42952         LDKNodeFeatures this_arg_conv;
42953         this_arg_conv.inner = untag_ptr(this_arg);
42954         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42956         this_arg_conv.is_owned = false;
42957         NodeFeatures_set_zero_conf_required(&this_arg_conv);
42958 }
42959
42960 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42961         LDKNodeFeatures this_arg_conv;
42962         this_arg_conv.inner = untag_ptr(this_arg);
42963         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42965         this_arg_conv.is_owned = false;
42966         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
42967         return ret_conv;
42968 }
42969
42970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
42971         LDKChannelTypeFeatures this_arg_conv;
42972         this_arg_conv.inner = untag_ptr(this_arg);
42973         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42975         this_arg_conv.is_owned = false;
42976         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
42977 }
42978
42979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
42980         LDKChannelTypeFeatures this_arg_conv;
42981         this_arg_conv.inner = untag_ptr(this_arg);
42982         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42984         this_arg_conv.is_owned = false;
42985         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
42986 }
42987
42988 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42989         LDKChannelTypeFeatures this_arg_conv;
42990         this_arg_conv.inner = untag_ptr(this_arg);
42991         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42993         this_arg_conv.is_owned = false;
42994         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
42995         return ret_conv;
42996 }
42997
42998 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
42999         LDKInitFeatures this_arg_conv;
43000         this_arg_conv.inner = untag_ptr(this_arg);
43001         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43003         this_arg_conv.is_owned = false;
43004         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
43005         return ret_conv;
43006 }
43007
43008 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
43009         LDKNodeFeatures this_arg_conv;
43010         this_arg_conv.inner = untag_ptr(this_arg);
43011         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43013         this_arg_conv.is_owned = false;
43014         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
43015         return ret_conv;
43016 }
43017
43018 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
43019         LDKChannelTypeFeatures this_arg_conv;
43020         this_arg_conv.inner = untag_ptr(this_arg);
43021         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43023         this_arg_conv.is_owned = false;
43024         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
43025         return ret_conv;
43026 }
43027
43028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
43029         LDKNodeFeatures this_arg_conv;
43030         this_arg_conv.inner = untag_ptr(this_arg);
43031         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43033         this_arg_conv.is_owned = false;
43034         NodeFeatures_set_keysend_optional(&this_arg_conv);
43035 }
43036
43037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
43038         LDKNodeFeatures this_arg_conv;
43039         this_arg_conv.inner = untag_ptr(this_arg);
43040         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43042         this_arg_conv.is_owned = false;
43043         NodeFeatures_set_keysend_required(&this_arg_conv);
43044 }
43045
43046 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
43047         LDKNodeFeatures this_arg_conv;
43048         this_arg_conv.inner = untag_ptr(this_arg);
43049         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43051         this_arg_conv.is_owned = false;
43052         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
43053         return ret_conv;
43054 }
43055
43056 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
43057         LDKNodeFeatures this_arg_conv;
43058         this_arg_conv.inner = untag_ptr(this_arg);
43059         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43061         this_arg_conv.is_owned = false;
43062         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
43063         return ret_conv;
43064 }
43065
43066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43067         LDKShutdownScript this_obj_conv;
43068         this_obj_conv.inner = untag_ptr(this_obj);
43069         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43071         ShutdownScript_free(this_obj_conv);
43072 }
43073
43074 static inline uint64_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
43075         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
43076         int64_t ret_ref = 0;
43077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43078         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43079         return ret_ref;
43080 }
43081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43082         LDKShutdownScript arg_conv;
43083         arg_conv.inner = untag_ptr(arg);
43084         arg_conv.is_owned = ptr_is_owned(arg);
43085         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43086         arg_conv.is_owned = false;
43087         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
43088         return ret_conv;
43089 }
43090
43091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43092         LDKShutdownScript orig_conv;
43093         orig_conv.inner = untag_ptr(orig);
43094         orig_conv.is_owned = ptr_is_owned(orig);
43095         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43096         orig_conv.is_owned = false;
43097         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
43098         int64_t ret_ref = 0;
43099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43100         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43101         return ret_ref;
43102 }
43103
43104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43105         LDKInvalidShutdownScript this_obj_conv;
43106         this_obj_conv.inner = untag_ptr(this_obj);
43107         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43109         InvalidShutdownScript_free(this_obj_conv);
43110 }
43111
43112 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
43113         LDKInvalidShutdownScript this_ptr_conv;
43114         this_ptr_conv.inner = untag_ptr(this_ptr);
43115         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43117         this_ptr_conv.is_owned = false;
43118         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
43119         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43120         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43121         return ret_arr;
43122 }
43123
43124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43125         LDKInvalidShutdownScript this_ptr_conv;
43126         this_ptr_conv.inner = untag_ptr(this_ptr);
43127         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43129         this_ptr_conv.is_owned = false;
43130         LDKCVec_u8Z val_ref;
43131         val_ref.datalen = (*env)->GetArrayLength(env, val);
43132         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
43133         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
43134         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
43135 }
43136
43137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
43138         LDKCVec_u8Z script_arg_ref;
43139         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
43140         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
43141         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
43142         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
43143         int64_t ret_ref = 0;
43144         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43145         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43146         return ret_ref;
43147 }
43148
43149 static inline uint64_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
43150         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
43151         int64_t ret_ref = 0;
43152         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43153         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43154         return ret_ref;
43155 }
43156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43157         LDKInvalidShutdownScript arg_conv;
43158         arg_conv.inner = untag_ptr(arg);
43159         arg_conv.is_owned = ptr_is_owned(arg);
43160         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43161         arg_conv.is_owned = false;
43162         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
43163         return ret_conv;
43164 }
43165
43166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43167         LDKInvalidShutdownScript orig_conv;
43168         orig_conv.inner = untag_ptr(orig);
43169         orig_conv.is_owned = ptr_is_owned(orig);
43170         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43171         orig_conv.is_owned = false;
43172         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
43173         int64_t ret_ref = 0;
43174         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43175         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43176         return ret_ref;
43177 }
43178
43179 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
43180         LDKShutdownScript obj_conv;
43181         obj_conv.inner = untag_ptr(obj);
43182         obj_conv.is_owned = ptr_is_owned(obj);
43183         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43184         obj_conv.is_owned = false;
43185         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
43186         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43187         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43188         CVec_u8Z_free(ret_var);
43189         return ret_arr;
43190 }
43191
43192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43193         LDKu8slice ser_ref;
43194         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43195         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43196         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
43197         *ret_conv = ShutdownScript_read(ser_ref);
43198         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43199         return tag_ptr(ret_conv, true);
43200 }
43201
43202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
43203         unsigned char pubkey_hash_arr[20];
43204         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
43205         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
43206         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
43207         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
43208         int64_t ret_ref = 0;
43209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43210         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43211         return ret_ref;
43212 }
43213
43214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
43215         unsigned char script_hash_arr[32];
43216         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
43217         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
43218         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
43219         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
43220         int64_t ret_ref = 0;
43221         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43222         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43223         return ret_ref;
43224 }
43225
43226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
43227         
43228         LDKu8slice program_ref;
43229         program_ref.datalen = (*env)->GetArrayLength(env, program);
43230         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
43231         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
43232         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
43233         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
43234         return tag_ptr(ret_conv, true);
43235 }
43236
43237 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
43238         LDKShutdownScript this_arg_conv;
43239         this_arg_conv.inner = untag_ptr(this_arg);
43240         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43241         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43242         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
43243         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
43244         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43245         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43246         CVec_u8Z_free(ret_var);
43247         return ret_arr;
43248 }
43249
43250 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
43251         LDKShutdownScript this_arg_conv;
43252         this_arg_conv.inner = untag_ptr(this_arg);
43253         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43254         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43255         this_arg_conv.is_owned = false;
43256         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
43257         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
43258         return ret_arr;
43259 }
43260
43261 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
43262         LDKShutdownScript this_arg_conv;
43263         this_arg_conv.inner = untag_ptr(this_arg);
43264         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43266         this_arg_conv.is_owned = false;
43267         LDKInitFeatures features_conv;
43268         features_conv.inner = untag_ptr(features);
43269         features_conv.is_owned = ptr_is_owned(features);
43270         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
43271         features_conv.is_owned = false;
43272         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
43273         return ret_conv;
43274 }
43275
43276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
43277         if (!ptr_is_owned(this_ptr)) return;
43278         void* this_ptr_ptr = untag_ptr(this_ptr);
43279         CHECK_ACCESS(this_ptr_ptr);
43280         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
43281         FREE(untag_ptr(this_ptr));
43282         CustomMessageReader_free(this_ptr_conv);
43283 }
43284
43285 static inline uint64_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
43286         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
43287         *ret_ret = Type_clone(arg);
43288         return tag_ptr(ret_ret, true);
43289 }
43290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43291         void* arg_ptr = untag_ptr(arg);
43292         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
43293         LDKType* arg_conv = (LDKType*)arg_ptr;
43294         int64_t ret_conv = Type_clone_ptr(arg_conv);
43295         return ret_conv;
43296 }
43297
43298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43299         void* orig_ptr = untag_ptr(orig);
43300         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
43301         LDKType* orig_conv = (LDKType*)orig_ptr;
43302         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
43303         *ret_ret = Type_clone(orig_conv);
43304         return tag_ptr(ret_ret, true);
43305 }
43306
43307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
43308         if (!ptr_is_owned(this_ptr)) return;
43309         void* this_ptr_ptr = untag_ptr(this_ptr);
43310         CHECK_ACCESS(this_ptr_ptr);
43311         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
43312         FREE(untag_ptr(this_ptr));
43313         Type_free(this_ptr_conv);
43314 }
43315
43316 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43317         LDKNodeId this_obj_conv;
43318         this_obj_conv.inner = untag_ptr(this_obj);
43319         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43321         NodeId_free(this_obj_conv);
43322 }
43323
43324 static inline uint64_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
43325         LDKNodeId ret_var = NodeId_clone(arg);
43326         int64_t ret_ref = 0;
43327         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43328         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43329         return ret_ref;
43330 }
43331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43332         LDKNodeId arg_conv;
43333         arg_conv.inner = untag_ptr(arg);
43334         arg_conv.is_owned = ptr_is_owned(arg);
43335         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43336         arg_conv.is_owned = false;
43337         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
43338         return ret_conv;
43339 }
43340
43341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43342         LDKNodeId orig_conv;
43343         orig_conv.inner = untag_ptr(orig);
43344         orig_conv.is_owned = ptr_is_owned(orig);
43345         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43346         orig_conv.is_owned = false;
43347         LDKNodeId ret_var = NodeId_clone(&orig_conv);
43348         int64_t ret_ref = 0;
43349         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43350         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43351         return ret_ref;
43352 }
43353
43354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
43355         LDKPublicKey pubkey_ref;
43356         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
43357         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
43358         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
43359         int64_t ret_ref = 0;
43360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43361         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43362         return ret_ref;
43363 }
43364
43365 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
43366         LDKNodeId this_arg_conv;
43367         this_arg_conv.inner = untag_ptr(this_arg);
43368         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43370         this_arg_conv.is_owned = false;
43371         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
43372         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43373         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43374         return ret_arr;
43375 }
43376
43377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
43378         LDKNodeId o_conv;
43379         o_conv.inner = untag_ptr(o);
43380         o_conv.is_owned = ptr_is_owned(o);
43381         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43382         o_conv.is_owned = false;
43383         int64_t ret_conv = NodeId_hash(&o_conv);
43384         return ret_conv;
43385 }
43386
43387 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
43388         LDKNodeId obj_conv;
43389         obj_conv.inner = untag_ptr(obj);
43390         obj_conv.is_owned = ptr_is_owned(obj);
43391         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43392         obj_conv.is_owned = false;
43393         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
43394         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43395         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43396         CVec_u8Z_free(ret_var);
43397         return ret_arr;
43398 }
43399
43400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43401         LDKu8slice ser_ref;
43402         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43403         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43404         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
43405         *ret_conv = NodeId_read(ser_ref);
43406         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43407         return tag_ptr(ret_conv, true);
43408 }
43409
43410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43411         LDKNetworkGraph this_obj_conv;
43412         this_obj_conv.inner = untag_ptr(this_obj);
43413         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43415         NetworkGraph_free(this_obj_conv);
43416 }
43417
43418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43419         LDKReadOnlyNetworkGraph this_obj_conv;
43420         this_obj_conv.inner = untag_ptr(this_obj);
43421         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43423         ReadOnlyNetworkGraph_free(this_obj_conv);
43424 }
43425
43426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
43427         if (!ptr_is_owned(this_ptr)) return;
43428         void* this_ptr_ptr = untag_ptr(this_ptr);
43429         CHECK_ACCESS(this_ptr_ptr);
43430         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
43431         FREE(untag_ptr(this_ptr));
43432         NetworkUpdate_free(this_ptr_conv);
43433 }
43434
43435 static inline uint64_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
43436         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
43437         *ret_copy = NetworkUpdate_clone(arg);
43438         int64_t ret_ref = tag_ptr(ret_copy, true);
43439         return ret_ref;
43440 }
43441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43442         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)untag_ptr(arg);
43443         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
43444         return ret_conv;
43445 }
43446
43447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43448         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)untag_ptr(orig);
43449         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
43450         *ret_copy = NetworkUpdate_clone(orig_conv);
43451         int64_t ret_ref = tag_ptr(ret_copy, true);
43452         return ret_ref;
43453 }
43454
43455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
43456         LDKChannelUpdate msg_conv;
43457         msg_conv.inner = untag_ptr(msg);
43458         msg_conv.is_owned = ptr_is_owned(msg);
43459         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
43460         msg_conv = ChannelUpdate_clone(&msg_conv);
43461         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
43462         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
43463         int64_t ret_ref = tag_ptr(ret_copy, true);
43464         return ret_ref;
43465 }
43466
43467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1failure(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
43468         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
43469         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
43470         int64_t ret_ref = tag_ptr(ret_copy, true);
43471         return ret_ref;
43472 }
43473
43474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
43475         LDKPublicKey node_id_ref;
43476         CHECK((*env)->GetArrayLength(env, node_id) == 33);
43477         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
43478         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
43479         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
43480         int64_t ret_ref = tag_ptr(ret_copy, true);
43481         return ret_ref;
43482 }
43483
43484 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
43485         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)untag_ptr(obj);
43486         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
43487         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43488         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43489         CVec_u8Z_free(ret_var);
43490         return ret_arr;
43491 }
43492
43493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43494         LDKu8slice ser_ref;
43495         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43496         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43497         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
43498         *ret_conv = NetworkUpdate_read(ser_ref);
43499         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43500         return tag_ptr(ret_conv, true);
43501 }
43502
43503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43504         LDKP2PGossipSync this_obj_conv;
43505         this_obj_conv.inner = untag_ptr(this_obj);
43506         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43508         P2PGossipSync_free(this_obj_conv);
43509 }
43510
43511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t chain_access, int64_t logger) {
43512         LDKNetworkGraph network_graph_conv;
43513         network_graph_conv.inner = untag_ptr(network_graph);
43514         network_graph_conv.is_owned = ptr_is_owned(network_graph);
43515         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
43516         network_graph_conv.is_owned = false;
43517         void* chain_access_ptr = untag_ptr(chain_access);
43518         CHECK_ACCESS(chain_access_ptr);
43519         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
43520         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
43521         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
43522                 // Manually implement clone for Java trait instances
43523                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
43524                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43525                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
43526                 }
43527         }
43528         void* logger_ptr = untag_ptr(logger);
43529         CHECK_ACCESS(logger_ptr);
43530         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
43531         if (logger_conv.free == LDKLogger_JCalls_free) {
43532                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43533                 LDKLogger_JCalls_cloned(&logger_conv);
43534         }
43535         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, chain_access_conv, logger_conv);
43536         int64_t ret_ref = 0;
43537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43538         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43539         return ret_ref;
43540 }
43541
43542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
43543         LDKP2PGossipSync this_arg_conv;
43544         this_arg_conv.inner = untag_ptr(this_arg);
43545         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43547         this_arg_conv.is_owned = false;
43548         void* chain_access_ptr = untag_ptr(chain_access);
43549         CHECK_ACCESS(chain_access_ptr);
43550         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
43551         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
43552         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
43553                 // Manually implement clone for Java trait instances
43554                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
43555                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
43556                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
43557                 }
43558         }
43559         P2PGossipSync_add_chain_access(&this_arg_conv, chain_access_conv);
43560 }
43561
43562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
43563         LDKNetworkGraph this_arg_conv;
43564         this_arg_conv.inner = untag_ptr(this_arg);
43565         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43567         this_arg_conv.is_owned = false;
43568         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
43569         *ret_ret = NetworkGraph_as_EventHandler(&this_arg_conv);
43570         return tag_ptr(ret_ret, true);
43571 }
43572
43573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
43574         LDKP2PGossipSync this_arg_conv;
43575         this_arg_conv.inner = untag_ptr(this_arg);
43576         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43578         this_arg_conv.is_owned = false;
43579         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
43580         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
43581         return tag_ptr(ret_ret, true);
43582 }
43583
43584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
43585         LDKP2PGossipSync this_arg_conv;
43586         this_arg_conv.inner = untag_ptr(this_arg);
43587         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43589         this_arg_conv.is_owned = false;
43590         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
43591         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
43592         return tag_ptr(ret_ret, true);
43593 }
43594
43595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43596         LDKChannelUpdateInfo this_obj_conv;
43597         this_obj_conv.inner = untag_ptr(this_obj);
43598         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43600         ChannelUpdateInfo_free(this_obj_conv);
43601 }
43602
43603 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
43604         LDKChannelUpdateInfo this_ptr_conv;
43605         this_ptr_conv.inner = untag_ptr(this_ptr);
43606         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43608         this_ptr_conv.is_owned = false;
43609         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
43610         return ret_conv;
43611 }
43612
43613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
43614         LDKChannelUpdateInfo this_ptr_conv;
43615         this_ptr_conv.inner = untag_ptr(this_ptr);
43616         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43618         this_ptr_conv.is_owned = false;
43619         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
43620 }
43621
43622 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
43623         LDKChannelUpdateInfo this_ptr_conv;
43624         this_ptr_conv.inner = untag_ptr(this_ptr);
43625         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43627         this_ptr_conv.is_owned = false;
43628         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
43629         return ret_conv;
43630 }
43631
43632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
43633         LDKChannelUpdateInfo this_ptr_conv;
43634         this_ptr_conv.inner = untag_ptr(this_ptr);
43635         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43637         this_ptr_conv.is_owned = false;
43638         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
43639 }
43640
43641 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
43642         LDKChannelUpdateInfo this_ptr_conv;
43643         this_ptr_conv.inner = untag_ptr(this_ptr);
43644         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43646         this_ptr_conv.is_owned = false;
43647         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
43648         return ret_conv;
43649 }
43650
43651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
43652         LDKChannelUpdateInfo this_ptr_conv;
43653         this_ptr_conv.inner = untag_ptr(this_ptr);
43654         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43656         this_ptr_conv.is_owned = false;
43657         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
43658 }
43659
43660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43661         LDKChannelUpdateInfo this_ptr_conv;
43662         this_ptr_conv.inner = untag_ptr(this_ptr);
43663         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43665         this_ptr_conv.is_owned = false;
43666         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
43667         return ret_conv;
43668 }
43669
43670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43671         LDKChannelUpdateInfo this_ptr_conv;
43672         this_ptr_conv.inner = untag_ptr(this_ptr);
43673         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43675         this_ptr_conv.is_owned = false;
43676         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
43677 }
43678
43679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
43680         LDKChannelUpdateInfo this_ptr_conv;
43681         this_ptr_conv.inner = untag_ptr(this_ptr);
43682         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43684         this_ptr_conv.is_owned = false;
43685         int64_t ret_conv = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
43686         return ret_conv;
43687 }
43688
43689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43690         LDKChannelUpdateInfo this_ptr_conv;
43691         this_ptr_conv.inner = untag_ptr(this_ptr);
43692         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43694         this_ptr_conv.is_owned = false;
43695         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
43696 }
43697
43698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
43699         LDKChannelUpdateInfo this_ptr_conv;
43700         this_ptr_conv.inner = untag_ptr(this_ptr);
43701         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43703         this_ptr_conv.is_owned = false;
43704         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
43705         int64_t ret_ref = 0;
43706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43707         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43708         return ret_ref;
43709 }
43710
43711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43712         LDKChannelUpdateInfo this_ptr_conv;
43713         this_ptr_conv.inner = untag_ptr(this_ptr);
43714         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43716         this_ptr_conv.is_owned = false;
43717         LDKRoutingFees val_conv;
43718         val_conv.inner = untag_ptr(val);
43719         val_conv.is_owned = ptr_is_owned(val);
43720         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43721         val_conv = RoutingFees_clone(&val_conv);
43722         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
43723 }
43724
43725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
43726         LDKChannelUpdateInfo this_ptr_conv;
43727         this_ptr_conv.inner = untag_ptr(this_ptr);
43728         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43730         this_ptr_conv.is_owned = false;
43731         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
43732         int64_t ret_ref = 0;
43733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43734         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43735         return ret_ref;
43736 }
43737
43738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43739         LDKChannelUpdateInfo this_ptr_conv;
43740         this_ptr_conv.inner = untag_ptr(this_ptr);
43741         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43743         this_ptr_conv.is_owned = false;
43744         LDKChannelUpdate val_conv;
43745         val_conv.inner = untag_ptr(val);
43746         val_conv.is_owned = ptr_is_owned(val);
43747         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43748         val_conv = ChannelUpdate_clone(&val_conv);
43749         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
43750 }
43751
43752 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) {
43753         LDKRoutingFees fees_arg_conv;
43754         fees_arg_conv.inner = untag_ptr(fees_arg);
43755         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
43756         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
43757         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
43758         LDKChannelUpdate last_update_message_arg_conv;
43759         last_update_message_arg_conv.inner = untag_ptr(last_update_message_arg);
43760         last_update_message_arg_conv.is_owned = ptr_is_owned(last_update_message_arg);
43761         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
43762         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
43763         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg, fees_arg_conv, last_update_message_arg_conv);
43764         int64_t ret_ref = 0;
43765         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43766         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43767         return ret_ref;
43768 }
43769
43770 static inline uint64_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
43771         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
43772         int64_t ret_ref = 0;
43773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43774         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43775         return ret_ref;
43776 }
43777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43778         LDKChannelUpdateInfo arg_conv;
43779         arg_conv.inner = untag_ptr(arg);
43780         arg_conv.is_owned = ptr_is_owned(arg);
43781         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43782         arg_conv.is_owned = false;
43783         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
43784         return ret_conv;
43785 }
43786
43787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43788         LDKChannelUpdateInfo orig_conv;
43789         orig_conv.inner = untag_ptr(orig);
43790         orig_conv.is_owned = ptr_is_owned(orig);
43791         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43792         orig_conv.is_owned = false;
43793         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
43794         int64_t ret_ref = 0;
43795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43796         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43797         return ret_ref;
43798 }
43799
43800 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
43801         LDKChannelUpdateInfo obj_conv;
43802         obj_conv.inner = untag_ptr(obj);
43803         obj_conv.is_owned = ptr_is_owned(obj);
43804         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43805         obj_conv.is_owned = false;
43806         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
43807         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43808         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43809         CVec_u8Z_free(ret_var);
43810         return ret_arr;
43811 }
43812
43813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43814         LDKu8slice ser_ref;
43815         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43816         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43817         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
43818         *ret_conv = ChannelUpdateInfo_read(ser_ref);
43819         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43820         return tag_ptr(ret_conv, true);
43821 }
43822
43823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43824         LDKChannelInfo this_obj_conv;
43825         this_obj_conv.inner = untag_ptr(this_obj);
43826         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43828         ChannelInfo_free(this_obj_conv);
43829 }
43830
43831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
43832         LDKChannelInfo this_ptr_conv;
43833         this_ptr_conv.inner = untag_ptr(this_ptr);
43834         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43836         this_ptr_conv.is_owned = false;
43837         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
43838         int64_t ret_ref = 0;
43839         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43840         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43841         return ret_ref;
43842 }
43843
43844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43845         LDKChannelInfo this_ptr_conv;
43846         this_ptr_conv.inner = untag_ptr(this_ptr);
43847         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43849         this_ptr_conv.is_owned = false;
43850         LDKChannelFeatures val_conv;
43851         val_conv.inner = untag_ptr(val);
43852         val_conv.is_owned = ptr_is_owned(val);
43853         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43854         val_conv = ChannelFeatures_clone(&val_conv);
43855         ChannelInfo_set_features(&this_ptr_conv, val_conv);
43856 }
43857
43858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
43859         LDKChannelInfo this_ptr_conv;
43860         this_ptr_conv.inner = untag_ptr(this_ptr);
43861         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43863         this_ptr_conv.is_owned = false;
43864         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
43865         int64_t ret_ref = 0;
43866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43867         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43868         return ret_ref;
43869 }
43870
43871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43872         LDKChannelInfo this_ptr_conv;
43873         this_ptr_conv.inner = untag_ptr(this_ptr);
43874         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43876         this_ptr_conv.is_owned = false;
43877         LDKNodeId val_conv;
43878         val_conv.inner = untag_ptr(val);
43879         val_conv.is_owned = ptr_is_owned(val);
43880         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43881         val_conv = NodeId_clone(&val_conv);
43882         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
43883 }
43884
43885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
43886         LDKChannelInfo this_ptr_conv;
43887         this_ptr_conv.inner = untag_ptr(this_ptr);
43888         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43890         this_ptr_conv.is_owned = false;
43891         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
43892         int64_t ret_ref = 0;
43893         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43894         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43895         return ret_ref;
43896 }
43897
43898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43899         LDKChannelInfo this_ptr_conv;
43900         this_ptr_conv.inner = untag_ptr(this_ptr);
43901         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43903         this_ptr_conv.is_owned = false;
43904         LDKChannelUpdateInfo val_conv;
43905         val_conv.inner = untag_ptr(val);
43906         val_conv.is_owned = ptr_is_owned(val);
43907         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43908         val_conv = ChannelUpdateInfo_clone(&val_conv);
43909         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
43910 }
43911
43912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
43913         LDKChannelInfo this_ptr_conv;
43914         this_ptr_conv.inner = untag_ptr(this_ptr);
43915         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43917         this_ptr_conv.is_owned = false;
43918         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
43919         int64_t ret_ref = 0;
43920         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43921         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43922         return ret_ref;
43923 }
43924
43925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43926         LDKChannelInfo this_ptr_conv;
43927         this_ptr_conv.inner = untag_ptr(this_ptr);
43928         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43930         this_ptr_conv.is_owned = false;
43931         LDKNodeId val_conv;
43932         val_conv.inner = untag_ptr(val);
43933         val_conv.is_owned = ptr_is_owned(val);
43934         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43935         val_conv = NodeId_clone(&val_conv);
43936         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
43937 }
43938
43939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
43940         LDKChannelInfo this_ptr_conv;
43941         this_ptr_conv.inner = untag_ptr(this_ptr);
43942         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43944         this_ptr_conv.is_owned = false;
43945         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
43946         int64_t ret_ref = 0;
43947         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43948         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43949         return ret_ref;
43950 }
43951
43952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43953         LDKChannelInfo this_ptr_conv;
43954         this_ptr_conv.inner = untag_ptr(this_ptr);
43955         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43957         this_ptr_conv.is_owned = false;
43958         LDKChannelUpdateInfo val_conv;
43959         val_conv.inner = untag_ptr(val);
43960         val_conv.is_owned = ptr_is_owned(val);
43961         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
43962         val_conv = ChannelUpdateInfo_clone(&val_conv);
43963         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
43964 }
43965
43966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
43967         LDKChannelInfo this_ptr_conv;
43968         this_ptr_conv.inner = untag_ptr(this_ptr);
43969         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43971         this_ptr_conv.is_owned = false;
43972         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
43973         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
43974         int64_t ret_ref = tag_ptr(ret_copy, true);
43975         return ret_ref;
43976 }
43977
43978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
43979         LDKChannelInfo this_ptr_conv;
43980         this_ptr_conv.inner = untag_ptr(this_ptr);
43981         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43983         this_ptr_conv.is_owned = false;
43984         void* val_ptr = untag_ptr(val);
43985         CHECK_ACCESS(val_ptr);
43986         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
43987         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
43988         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
43989 }
43990
43991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
43992         LDKChannelInfo this_ptr_conv;
43993         this_ptr_conv.inner = untag_ptr(this_ptr);
43994         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43996         this_ptr_conv.is_owned = false;
43997         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
43998         int64_t ret_ref = 0;
43999         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44000         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44001         return ret_ref;
44002 }
44003
44004 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44005         LDKChannelInfo this_ptr_conv;
44006         this_ptr_conv.inner = untag_ptr(this_ptr);
44007         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44008         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44009         this_ptr_conv.is_owned = false;
44010         LDKChannelAnnouncement val_conv;
44011         val_conv.inner = untag_ptr(val);
44012         val_conv.is_owned = ptr_is_owned(val);
44013         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44014         val_conv = ChannelAnnouncement_clone(&val_conv);
44015         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
44016 }
44017
44018 static inline uint64_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
44019         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
44020         int64_t ret_ref = 0;
44021         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44022         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44023         return ret_ref;
44024 }
44025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44026         LDKChannelInfo arg_conv;
44027         arg_conv.inner = untag_ptr(arg);
44028         arg_conv.is_owned = ptr_is_owned(arg);
44029         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44030         arg_conv.is_owned = false;
44031         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
44032         return ret_conv;
44033 }
44034
44035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44036         LDKChannelInfo orig_conv;
44037         orig_conv.inner = untag_ptr(orig);
44038         orig_conv.is_owned = ptr_is_owned(orig);
44039         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44040         orig_conv.is_owned = false;
44041         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
44042         int64_t ret_ref = 0;
44043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44044         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44045         return ret_ref;
44046 }
44047
44048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1directional_1info(JNIEnv *env, jclass clz, int64_t this_arg, int8_t channel_flags) {
44049         LDKChannelInfo this_arg_conv;
44050         this_arg_conv.inner = untag_ptr(this_arg);
44051         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44053         this_arg_conv.is_owned = false;
44054         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
44055         int64_t ret_ref = 0;
44056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44057         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44058         return ret_ref;
44059 }
44060
44061 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
44062         LDKChannelInfo obj_conv;
44063         obj_conv.inner = untag_ptr(obj);
44064         obj_conv.is_owned = ptr_is_owned(obj);
44065         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44066         obj_conv.is_owned = false;
44067         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
44068         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44069         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44070         CVec_u8Z_free(ret_var);
44071         return ret_arr;
44072 }
44073
44074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44075         LDKu8slice ser_ref;
44076         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44077         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44078         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
44079         *ret_conv = ChannelInfo_read(ser_ref);
44080         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44081         return tag_ptr(ret_conv, true);
44082 }
44083
44084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44085         LDKDirectedChannelInfo this_obj_conv;
44086         this_obj_conv.inner = untag_ptr(this_obj);
44087         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44089         DirectedChannelInfo_free(this_obj_conv);
44090 }
44091
44092 static inline uint64_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
44093         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
44094         int64_t ret_ref = 0;
44095         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44096         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44097         return ret_ref;
44098 }
44099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44100         LDKDirectedChannelInfo arg_conv;
44101         arg_conv.inner = untag_ptr(arg);
44102         arg_conv.is_owned = ptr_is_owned(arg);
44103         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44104         arg_conv.is_owned = false;
44105         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
44106         return ret_conv;
44107 }
44108
44109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44110         LDKDirectedChannelInfo orig_conv;
44111         orig_conv.inner = untag_ptr(orig);
44112         orig_conv.is_owned = ptr_is_owned(orig);
44113         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44114         orig_conv.is_owned = false;
44115         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
44116         int64_t ret_ref = 0;
44117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44118         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44119         return ret_ref;
44120 }
44121
44122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
44123         LDKDirectedChannelInfo this_arg_conv;
44124         this_arg_conv.inner = untag_ptr(this_arg);
44125         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44127         this_arg_conv.is_owned = false;
44128         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
44129         int64_t ret_ref = 0;
44130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44131         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44132         return ret_ref;
44133 }
44134
44135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1direction(JNIEnv *env, jclass clz, int64_t this_arg) {
44136         LDKDirectedChannelInfo this_arg_conv;
44137         this_arg_conv.inner = untag_ptr(this_arg);
44138         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44140         this_arg_conv.is_owned = false;
44141         LDKChannelUpdateInfo ret_var = DirectedChannelInfo_direction(&this_arg_conv);
44142         int64_t ret_ref = 0;
44143         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44144         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44145         return ret_ref;
44146 }
44147
44148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
44149         LDKDirectedChannelInfo this_arg_conv;
44150         this_arg_conv.inner = untag_ptr(this_arg);
44151         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44153         this_arg_conv.is_owned = false;
44154         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
44155         return ret_conv;
44156 }
44157
44158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
44159         LDKDirectedChannelInfo this_arg_conv;
44160         this_arg_conv.inner = untag_ptr(this_arg);
44161         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44163         this_arg_conv.is_owned = false;
44164         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
44165         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
44166         int64_t ret_ref = tag_ptr(ret_copy, true);
44167         return ret_ref;
44168 }
44169
44170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
44171         if (!ptr_is_owned(this_ptr)) return;
44172         void* this_ptr_ptr = untag_ptr(this_ptr);
44173         CHECK_ACCESS(this_ptr_ptr);
44174         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
44175         FREE(untag_ptr(this_ptr));
44176         EffectiveCapacity_free(this_ptr_conv);
44177 }
44178
44179 static inline uint64_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
44180         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
44181         *ret_copy = EffectiveCapacity_clone(arg);
44182         int64_t ret_ref = tag_ptr(ret_copy, true);
44183         return ret_ref;
44184 }
44185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44186         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)untag_ptr(arg);
44187         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
44188         return ret_conv;
44189 }
44190
44191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44192         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)untag_ptr(orig);
44193         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
44194         *ret_copy = EffectiveCapacity_clone(orig_conv);
44195         int64_t ret_ref = tag_ptr(ret_copy, true);
44196         return ret_ref;
44197 }
44198
44199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
44200         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
44201         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
44202         int64_t ret_ref = tag_ptr(ret_copy, true);
44203         return ret_ref;
44204 }
44205
44206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
44207         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
44208         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
44209         int64_t ret_ref = tag_ptr(ret_copy, true);
44210         return ret_ref;
44211 }
44212
44213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat, int64_t htlc_maximum_msat) {
44214         void* htlc_maximum_msat_ptr = untag_ptr(htlc_maximum_msat);
44215         CHECK_ACCESS(htlc_maximum_msat_ptr);
44216         LDKCOption_u64Z htlc_maximum_msat_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_ptr);
44217         htlc_maximum_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_maximum_msat));
44218         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
44219         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat_conv);
44220         int64_t ret_ref = tag_ptr(ret_copy, true);
44221         return ret_ref;
44222 }
44223
44224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
44225         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
44226         *ret_copy = EffectiveCapacity_infinite();
44227         int64_t ret_ref = tag_ptr(ret_copy, true);
44228         return ret_ref;
44229 }
44230
44231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
44232         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
44233         *ret_copy = EffectiveCapacity_unknown();
44234         int64_t ret_ref = tag_ptr(ret_copy, true);
44235         return ret_ref;
44236 }
44237
44238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
44239         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)untag_ptr(this_arg);
44240         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
44241         return ret_conv;
44242 }
44243
44244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44245         LDKRoutingFees this_obj_conv;
44246         this_obj_conv.inner = untag_ptr(this_obj);
44247         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44249         RoutingFees_free(this_obj_conv);
44250 }
44251
44252 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
44253         LDKRoutingFees this_ptr_conv;
44254         this_ptr_conv.inner = untag_ptr(this_ptr);
44255         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44257         this_ptr_conv.is_owned = false;
44258         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
44259         return ret_conv;
44260 }
44261
44262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
44263         LDKRoutingFees this_ptr_conv;
44264         this_ptr_conv.inner = untag_ptr(this_ptr);
44265         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44267         this_ptr_conv.is_owned = false;
44268         RoutingFees_set_base_msat(&this_ptr_conv, val);
44269 }
44270
44271 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
44272         LDKRoutingFees this_ptr_conv;
44273         this_ptr_conv.inner = untag_ptr(this_ptr);
44274         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44276         this_ptr_conv.is_owned = false;
44277         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
44278         return ret_conv;
44279 }
44280
44281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
44282         LDKRoutingFees this_ptr_conv;
44283         this_ptr_conv.inner = untag_ptr(this_ptr);
44284         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44286         this_ptr_conv.is_owned = false;
44287         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
44288 }
44289
44290 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) {
44291         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
44292         int64_t ret_ref = 0;
44293         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44294         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44295         return ret_ref;
44296 }
44297
44298 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
44299         LDKRoutingFees a_conv;
44300         a_conv.inner = untag_ptr(a);
44301         a_conv.is_owned = ptr_is_owned(a);
44302         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
44303         a_conv.is_owned = false;
44304         LDKRoutingFees b_conv;
44305         b_conv.inner = untag_ptr(b);
44306         b_conv.is_owned = ptr_is_owned(b);
44307         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
44308         b_conv.is_owned = false;
44309         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
44310         return ret_conv;
44311 }
44312
44313 static inline uint64_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
44314         LDKRoutingFees ret_var = RoutingFees_clone(arg);
44315         int64_t ret_ref = 0;
44316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44317         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44318         return ret_ref;
44319 }
44320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44321         LDKRoutingFees arg_conv;
44322         arg_conv.inner = untag_ptr(arg);
44323         arg_conv.is_owned = ptr_is_owned(arg);
44324         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44325         arg_conv.is_owned = false;
44326         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
44327         return ret_conv;
44328 }
44329
44330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44331         LDKRoutingFees orig_conv;
44332         orig_conv.inner = untag_ptr(orig);
44333         orig_conv.is_owned = ptr_is_owned(orig);
44334         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44335         orig_conv.is_owned = false;
44336         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
44337         int64_t ret_ref = 0;
44338         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44339         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44340         return ret_ref;
44341 }
44342
44343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
44344         LDKRoutingFees o_conv;
44345         o_conv.inner = untag_ptr(o);
44346         o_conv.is_owned = ptr_is_owned(o);
44347         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
44348         o_conv.is_owned = false;
44349         int64_t ret_conv = RoutingFees_hash(&o_conv);
44350         return ret_conv;
44351 }
44352
44353 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
44354         LDKRoutingFees obj_conv;
44355         obj_conv.inner = untag_ptr(obj);
44356         obj_conv.is_owned = ptr_is_owned(obj);
44357         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44358         obj_conv.is_owned = false;
44359         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
44360         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44361         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44362         CVec_u8Z_free(ret_var);
44363         return ret_arr;
44364 }
44365
44366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44367         LDKu8slice ser_ref;
44368         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44369         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44370         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
44371         *ret_conv = RoutingFees_read(ser_ref);
44372         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44373         return tag_ptr(ret_conv, true);
44374 }
44375
44376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44377         LDKNodeAnnouncementInfo this_obj_conv;
44378         this_obj_conv.inner = untag_ptr(this_obj);
44379         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44381         NodeAnnouncementInfo_free(this_obj_conv);
44382 }
44383
44384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
44385         LDKNodeAnnouncementInfo this_ptr_conv;
44386         this_ptr_conv.inner = untag_ptr(this_ptr);
44387         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44389         this_ptr_conv.is_owned = false;
44390         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
44391         int64_t ret_ref = 0;
44392         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44393         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44394         return ret_ref;
44395 }
44396
44397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44398         LDKNodeAnnouncementInfo this_ptr_conv;
44399         this_ptr_conv.inner = untag_ptr(this_ptr);
44400         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44402         this_ptr_conv.is_owned = false;
44403         LDKNodeFeatures val_conv;
44404         val_conv.inner = untag_ptr(val);
44405         val_conv.is_owned = ptr_is_owned(val);
44406         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44407         val_conv = NodeFeatures_clone(&val_conv);
44408         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
44409 }
44410
44411 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
44412         LDKNodeAnnouncementInfo this_ptr_conv;
44413         this_ptr_conv.inner = untag_ptr(this_ptr);
44414         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44416         this_ptr_conv.is_owned = false;
44417         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
44418         return ret_conv;
44419 }
44420
44421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
44422         LDKNodeAnnouncementInfo this_ptr_conv;
44423         this_ptr_conv.inner = untag_ptr(this_ptr);
44424         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44426         this_ptr_conv.is_owned = false;
44427         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
44428 }
44429
44430 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
44431         LDKNodeAnnouncementInfo this_ptr_conv;
44432         this_ptr_conv.inner = untag_ptr(this_ptr);
44433         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44435         this_ptr_conv.is_owned = false;
44436         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
44437         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
44438         return ret_arr;
44439 }
44440
44441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
44442         LDKNodeAnnouncementInfo this_ptr_conv;
44443         this_ptr_conv.inner = untag_ptr(this_ptr);
44444         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44446         this_ptr_conv.is_owned = false;
44447         LDKThreeBytes val_ref;
44448         CHECK((*env)->GetArrayLength(env, val) == 3);
44449         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
44450         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
44451 }
44452
44453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
44454         LDKNodeAnnouncementInfo this_ptr_conv;
44455         this_ptr_conv.inner = untag_ptr(this_ptr);
44456         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44458         this_ptr_conv.is_owned = false;
44459         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&this_ptr_conv);
44460         int64_t ret_ref = 0;
44461         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44462         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44463         return ret_ref;
44464 }
44465
44466 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44467         LDKNodeAnnouncementInfo this_ptr_conv;
44468         this_ptr_conv.inner = untag_ptr(this_ptr);
44469         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44471         this_ptr_conv.is_owned = false;
44472         LDKNodeAlias val_conv;
44473         val_conv.inner = untag_ptr(val);
44474         val_conv.is_owned = ptr_is_owned(val);
44475         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44476         val_conv = NodeAlias_clone(&val_conv);
44477         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
44478 }
44479
44480 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr) {
44481         LDKNodeAnnouncementInfo this_ptr_conv;
44482         this_ptr_conv.inner = untag_ptr(this_ptr);
44483         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44485         this_ptr_conv.is_owned = false;
44486         LDKCVec_NetAddressZ ret_var = NodeAnnouncementInfo_get_addresses(&this_ptr_conv);
44487         int64_tArray ret_arr = NULL;
44488         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44489         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44490         for (size_t m = 0; m < ret_var.datalen; m++) {
44491                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
44492                 *ret_conv_12_copy = ret_var.data[m];
44493                 int64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
44494                 ret_arr_ptr[m] = ret_conv_12_ref;
44495         }
44496         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44497         FREE(ret_var.data);
44498         return ret_arr;
44499 }
44500
44501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
44502         LDKNodeAnnouncementInfo this_ptr_conv;
44503         this_ptr_conv.inner = untag_ptr(this_ptr);
44504         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44505         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44506         this_ptr_conv.is_owned = false;
44507         LDKCVec_NetAddressZ val_constr;
44508         val_constr.datalen = (*env)->GetArrayLength(env, val);
44509         if (val_constr.datalen > 0)
44510                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
44511         else
44512                 val_constr.data = NULL;
44513         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
44514         for (size_t m = 0; m < val_constr.datalen; m++) {
44515                 int64_t val_conv_12 = val_vals[m];
44516                 void* val_conv_12_ptr = untag_ptr(val_conv_12);
44517                 CHECK_ACCESS(val_conv_12_ptr);
44518                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
44519                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(val_conv_12));
44520                 val_constr.data[m] = val_conv_12_conv;
44521         }
44522         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
44523         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
44524 }
44525
44526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
44527         LDKNodeAnnouncementInfo this_ptr_conv;
44528         this_ptr_conv.inner = untag_ptr(this_ptr);
44529         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44531         this_ptr_conv.is_owned = false;
44532         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
44533         int64_t ret_ref = 0;
44534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44535         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44536         return ret_ref;
44537 }
44538
44539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44540         LDKNodeAnnouncementInfo this_ptr_conv;
44541         this_ptr_conv.inner = untag_ptr(this_ptr);
44542         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44544         this_ptr_conv.is_owned = false;
44545         LDKNodeAnnouncement val_conv;
44546         val_conv.inner = untag_ptr(val);
44547         val_conv.is_owned = ptr_is_owned(val);
44548         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44549         val_conv = NodeAnnouncement_clone(&val_conv);
44550         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
44551 }
44552
44553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1new(JNIEnv *env, jclass clz, int64_t features_arg, int32_t last_update_arg, int8_tArray rgb_arg, int64_t alias_arg, int64_tArray addresses_arg, int64_t announcement_message_arg) {
44554         LDKNodeFeatures features_arg_conv;
44555         features_arg_conv.inner = untag_ptr(features_arg);
44556         features_arg_conv.is_owned = ptr_is_owned(features_arg);
44557         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
44558         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
44559         LDKThreeBytes rgb_arg_ref;
44560         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
44561         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
44562         LDKNodeAlias alias_arg_conv;
44563         alias_arg_conv.inner = untag_ptr(alias_arg);
44564         alias_arg_conv.is_owned = ptr_is_owned(alias_arg);
44565         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
44566         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
44567         LDKCVec_NetAddressZ addresses_arg_constr;
44568         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
44569         if (addresses_arg_constr.datalen > 0)
44570                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
44571         else
44572                 addresses_arg_constr.data = NULL;
44573         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
44574         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
44575                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
44576                 void* addresses_arg_conv_12_ptr = untag_ptr(addresses_arg_conv_12);
44577                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
44578                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
44579                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
44580         }
44581         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
44582         LDKNodeAnnouncement announcement_message_arg_conv;
44583         announcement_message_arg_conv.inner = untag_ptr(announcement_message_arg);
44584         announcement_message_arg_conv.is_owned = ptr_is_owned(announcement_message_arg);
44585         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
44586         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
44587         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, addresses_arg_constr, announcement_message_arg_conv);
44588         int64_t ret_ref = 0;
44589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44590         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44591         return ret_ref;
44592 }
44593
44594 static inline uint64_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
44595         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
44596         int64_t ret_ref = 0;
44597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44598         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44599         return ret_ref;
44600 }
44601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44602         LDKNodeAnnouncementInfo arg_conv;
44603         arg_conv.inner = untag_ptr(arg);
44604         arg_conv.is_owned = ptr_is_owned(arg);
44605         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44606         arg_conv.is_owned = false;
44607         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
44608         return ret_conv;
44609 }
44610
44611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44612         LDKNodeAnnouncementInfo orig_conv;
44613         orig_conv.inner = untag_ptr(orig);
44614         orig_conv.is_owned = ptr_is_owned(orig);
44615         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44616         orig_conv.is_owned = false;
44617         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
44618         int64_t ret_ref = 0;
44619         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44620         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44621         return ret_ref;
44622 }
44623
44624 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
44625         LDKNodeAnnouncementInfo obj_conv;
44626         obj_conv.inner = untag_ptr(obj);
44627         obj_conv.is_owned = ptr_is_owned(obj);
44628         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44629         obj_conv.is_owned = false;
44630         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
44631         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44632         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44633         CVec_u8Z_free(ret_var);
44634         return ret_arr;
44635 }
44636
44637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44638         LDKu8slice ser_ref;
44639         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44640         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44641         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
44642         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
44643         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44644         return tag_ptr(ret_conv, true);
44645 }
44646
44647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44648         LDKNodeAlias this_obj_conv;
44649         this_obj_conv.inner = untag_ptr(this_obj);
44650         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44652         NodeAlias_free(this_obj_conv);
44653 }
44654
44655 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
44656         LDKNodeAlias this_ptr_conv;
44657         this_ptr_conv.inner = untag_ptr(this_ptr);
44658         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44660         this_ptr_conv.is_owned = false;
44661         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
44662         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAlias_get_a(&this_ptr_conv));
44663         return ret_arr;
44664 }
44665
44666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
44667         LDKNodeAlias this_ptr_conv;
44668         this_ptr_conv.inner = untag_ptr(this_ptr);
44669         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44671         this_ptr_conv.is_owned = false;
44672         LDKThirtyTwoBytes val_ref;
44673         CHECK((*env)->GetArrayLength(env, val) == 32);
44674         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
44675         NodeAlias_set_a(&this_ptr_conv, val_ref);
44676 }
44677
44678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
44679         LDKThirtyTwoBytes a_arg_ref;
44680         CHECK((*env)->GetArrayLength(env, a_arg) == 32);
44681         (*env)->GetByteArrayRegion(env, a_arg, 0, 32, a_arg_ref.data);
44682         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
44683         int64_t ret_ref = 0;
44684         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44685         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44686         return ret_ref;
44687 }
44688
44689 static inline uint64_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
44690         LDKNodeAlias ret_var = NodeAlias_clone(arg);
44691         int64_t ret_ref = 0;
44692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44693         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44694         return ret_ref;
44695 }
44696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44697         LDKNodeAlias arg_conv;
44698         arg_conv.inner = untag_ptr(arg);
44699         arg_conv.is_owned = ptr_is_owned(arg);
44700         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44701         arg_conv.is_owned = false;
44702         int64_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
44703         return ret_conv;
44704 }
44705
44706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44707         LDKNodeAlias orig_conv;
44708         orig_conv.inner = untag_ptr(orig);
44709         orig_conv.is_owned = ptr_is_owned(orig);
44710         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44711         orig_conv.is_owned = false;
44712         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
44713         int64_t ret_ref = 0;
44714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44715         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44716         return ret_ref;
44717 }
44718
44719 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1write(JNIEnv *env, jclass clz, int64_t obj) {
44720         LDKNodeAlias obj_conv;
44721         obj_conv.inner = untag_ptr(obj);
44722         obj_conv.is_owned = ptr_is_owned(obj);
44723         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44724         obj_conv.is_owned = false;
44725         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
44726         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44727         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44728         CVec_u8Z_free(ret_var);
44729         return ret_arr;
44730 }
44731
44732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44733         LDKu8slice ser_ref;
44734         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44735         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44736         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
44737         *ret_conv = NodeAlias_read(ser_ref);
44738         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44739         return tag_ptr(ret_conv, true);
44740 }
44741
44742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
44743         LDKNodeInfo this_obj_conv;
44744         this_obj_conv.inner = untag_ptr(this_obj);
44745         this_obj_conv.is_owned = ptr_is_owned(this_obj);
44746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
44747         NodeInfo_free(this_obj_conv);
44748 }
44749
44750 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
44751         LDKNodeInfo this_ptr_conv;
44752         this_ptr_conv.inner = untag_ptr(this_ptr);
44753         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44755         this_ptr_conv.is_owned = false;
44756         LDKCVec_u64Z ret_var = NodeInfo_get_channels(&this_ptr_conv);
44757         int64_tArray ret_arr = NULL;
44758         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
44759         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
44760         for (size_t g = 0; g < ret_var.datalen; g++) {
44761                 int64_t ret_conv_6_conv = ret_var.data[g];
44762                 ret_arr_ptr[g] = ret_conv_6_conv;
44763         }
44764         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
44765         FREE(ret_var.data);
44766         return ret_arr;
44767 }
44768
44769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
44770         LDKNodeInfo this_ptr_conv;
44771         this_ptr_conv.inner = untag_ptr(this_ptr);
44772         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44774         this_ptr_conv.is_owned = false;
44775         LDKCVec_u64Z val_constr;
44776         val_constr.datalen = (*env)->GetArrayLength(env, val);
44777         if (val_constr.datalen > 0)
44778                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
44779         else
44780                 val_constr.data = NULL;
44781         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
44782         for (size_t g = 0; g < val_constr.datalen; g++) {
44783                 int64_t val_conv_6 = val_vals[g];
44784                 val_constr.data[g] = val_conv_6;
44785         }
44786         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
44787         NodeInfo_set_channels(&this_ptr_conv, val_constr);
44788 }
44789
44790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
44791         LDKNodeInfo this_ptr_conv;
44792         this_ptr_conv.inner = untag_ptr(this_ptr);
44793         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44795         this_ptr_conv.is_owned = false;
44796         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
44797         int64_t ret_ref = 0;
44798         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44799         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44800         return ret_ref;
44801 }
44802
44803 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) {
44804         LDKNodeInfo this_ptr_conv;
44805         this_ptr_conv.inner = untag_ptr(this_ptr);
44806         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44808         this_ptr_conv.is_owned = false;
44809         LDKRoutingFees val_conv;
44810         val_conv.inner = untag_ptr(val);
44811         val_conv.is_owned = ptr_is_owned(val);
44812         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44813         val_conv = RoutingFees_clone(&val_conv);
44814         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
44815 }
44816
44817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
44818         LDKNodeInfo this_ptr_conv;
44819         this_ptr_conv.inner = untag_ptr(this_ptr);
44820         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44822         this_ptr_conv.is_owned = false;
44823         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
44824         int64_t ret_ref = 0;
44825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44826         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44827         return ret_ref;
44828 }
44829
44830 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
44831         LDKNodeInfo this_ptr_conv;
44832         this_ptr_conv.inner = untag_ptr(this_ptr);
44833         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
44834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
44835         this_ptr_conv.is_owned = false;
44836         LDKNodeAnnouncementInfo val_conv;
44837         val_conv.inner = untag_ptr(val);
44838         val_conv.is_owned = ptr_is_owned(val);
44839         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
44840         val_conv = NodeAnnouncementInfo_clone(&val_conv);
44841         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
44842 }
44843
44844 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) {
44845         LDKCVec_u64Z channels_arg_constr;
44846         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
44847         if (channels_arg_constr.datalen > 0)
44848                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
44849         else
44850                 channels_arg_constr.data = NULL;
44851         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
44852         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
44853                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
44854                 channels_arg_constr.data[g] = channels_arg_conv_6;
44855         }
44856         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
44857         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
44858         lowest_inbound_channel_fees_arg_conv.inner = untag_ptr(lowest_inbound_channel_fees_arg);
44859         lowest_inbound_channel_fees_arg_conv.is_owned = ptr_is_owned(lowest_inbound_channel_fees_arg);
44860         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
44861         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
44862         LDKNodeAnnouncementInfo announcement_info_arg_conv;
44863         announcement_info_arg_conv.inner = untag_ptr(announcement_info_arg);
44864         announcement_info_arg_conv.is_owned = ptr_is_owned(announcement_info_arg);
44865         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
44866         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
44867         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
44868         int64_t ret_ref = 0;
44869         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44870         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44871         return ret_ref;
44872 }
44873
44874 static inline uint64_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
44875         LDKNodeInfo ret_var = NodeInfo_clone(arg);
44876         int64_t ret_ref = 0;
44877         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44878         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44879         return ret_ref;
44880 }
44881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
44882         LDKNodeInfo arg_conv;
44883         arg_conv.inner = untag_ptr(arg);
44884         arg_conv.is_owned = ptr_is_owned(arg);
44885         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
44886         arg_conv.is_owned = false;
44887         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
44888         return ret_conv;
44889 }
44890
44891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
44892         LDKNodeInfo orig_conv;
44893         orig_conv.inner = untag_ptr(orig);
44894         orig_conv.is_owned = ptr_is_owned(orig);
44895         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
44896         orig_conv.is_owned = false;
44897         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
44898         int64_t ret_ref = 0;
44899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44900         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44901         return ret_ref;
44902 }
44903
44904 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
44905         LDKNodeInfo obj_conv;
44906         obj_conv.inner = untag_ptr(obj);
44907         obj_conv.is_owned = ptr_is_owned(obj);
44908         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44909         obj_conv.is_owned = false;
44910         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
44911         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44912         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44913         CVec_u8Z_free(ret_var);
44914         return ret_arr;
44915 }
44916
44917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44918         LDKu8slice ser_ref;
44919         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44920         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44921         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
44922         *ret_conv = NodeInfo_read(ser_ref);
44923         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44924         return tag_ptr(ret_conv, true);
44925 }
44926
44927 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
44928         LDKNetworkGraph obj_conv;
44929         obj_conv.inner = untag_ptr(obj);
44930         obj_conv.is_owned = ptr_is_owned(obj);
44931         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44932         obj_conv.is_owned = false;
44933         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
44934         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44935         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44936         CVec_u8Z_free(ret_var);
44937         return ret_arr;
44938 }
44939
44940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
44941         LDKu8slice ser_ref;
44942         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44943         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44944         void* arg_ptr = untag_ptr(arg);
44945         CHECK_ACCESS(arg_ptr);
44946         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
44947         if (arg_conv.free == LDKLogger_JCalls_free) {
44948                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44949                 LDKLogger_JCalls_cloned(&arg_conv);
44950         }
44951         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
44952         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
44953         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44954         return tag_ptr(ret_conv, true);
44955 }
44956
44957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash, int64_t logger) {
44958         LDKThirtyTwoBytes genesis_hash_ref;
44959         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
44960         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
44961         void* logger_ptr = untag_ptr(logger);
44962         CHECK_ACCESS(logger_ptr);
44963         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
44964         if (logger_conv.free == LDKLogger_JCalls_free) {
44965                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
44966                 LDKLogger_JCalls_cloned(&logger_conv);
44967         }
44968         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref, logger_conv);
44969         int64_t ret_ref = 0;
44970         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44971         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44972         return ret_ref;
44973 }
44974
44975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
44976         LDKNetworkGraph this_arg_conv;
44977         this_arg_conv.inner = untag_ptr(this_arg);
44978         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44980         this_arg_conv.is_owned = false;
44981         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
44982         int64_t ret_ref = 0;
44983         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44984         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44985         return ret_ref;
44986 }
44987
44988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1get_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
44989         LDKNetworkGraph this_arg_conv;
44990         this_arg_conv.inner = untag_ptr(this_arg);
44991         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44993         this_arg_conv.is_owned = false;
44994         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
44995         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
44996         int64_t ret_ref = tag_ptr(ret_copy, true);
44997         return ret_ref;
44998 }
44999
45000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1set_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg, int32_t last_rapid_gossip_sync_timestamp) {
45001         LDKNetworkGraph this_arg_conv;
45002         this_arg_conv.inner = untag_ptr(this_arg);
45003         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45005         this_arg_conv.is_owned = false;
45006         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
45007 }
45008
45009 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) {
45010         LDKNetworkGraph this_arg_conv;
45011         this_arg_conv.inner = untag_ptr(this_arg);
45012         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45014         this_arg_conv.is_owned = false;
45015         LDKNodeAnnouncement msg_conv;
45016         msg_conv.inner = untag_ptr(msg);
45017         msg_conv.is_owned = ptr_is_owned(msg);
45018         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
45019         msg_conv.is_owned = false;
45020         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
45021         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
45022         return tag_ptr(ret_conv, true);
45023 }
45024
45025 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) {
45026         LDKNetworkGraph this_arg_conv;
45027         this_arg_conv.inner = untag_ptr(this_arg);
45028         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45030         this_arg_conv.is_owned = false;
45031         LDKUnsignedNodeAnnouncement msg_conv;
45032         msg_conv.inner = untag_ptr(msg);
45033         msg_conv.is_owned = ptr_is_owned(msg);
45034         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
45035         msg_conv.is_owned = false;
45036         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
45037         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
45038         return tag_ptr(ret_conv, true);
45039 }
45040
45041 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) {
45042         LDKNetworkGraph this_arg_conv;
45043         this_arg_conv.inner = untag_ptr(this_arg);
45044         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45046         this_arg_conv.is_owned = false;
45047         LDKChannelAnnouncement msg_conv;
45048         msg_conv.inner = untag_ptr(msg);
45049         msg_conv.is_owned = ptr_is_owned(msg);
45050         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
45051         msg_conv.is_owned = false;
45052         void* chain_access_ptr = untag_ptr(chain_access);
45053         CHECK_ACCESS(chain_access_ptr);
45054         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
45055         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
45056         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
45057                 // Manually implement clone for Java trait instances
45058                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
45059                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45060                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
45061                 }
45062         }
45063         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
45064         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
45065         return tag_ptr(ret_conv, true);
45066 }
45067
45068 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) {
45069         LDKNetworkGraph this_arg_conv;
45070         this_arg_conv.inner = untag_ptr(this_arg);
45071         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45073         this_arg_conv.is_owned = false;
45074         LDKUnsignedChannelAnnouncement msg_conv;
45075         msg_conv.inner = untag_ptr(msg);
45076         msg_conv.is_owned = ptr_is_owned(msg);
45077         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
45078         msg_conv.is_owned = false;
45079         void* chain_access_ptr = untag_ptr(chain_access);
45080         CHECK_ACCESS(chain_access_ptr);
45081         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
45082         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
45083         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
45084                 // Manually implement clone for Java trait instances
45085                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
45086                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
45087                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
45088                 }
45089         }
45090         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
45091         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
45092         return tag_ptr(ret_conv, true);
45093 }
45094
45095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1add_1channel_1from_1partial_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, int64_t timestamp, int64_t features, int8_tArray node_id_1, int8_tArray node_id_2) {
45096         LDKNetworkGraph this_arg_conv;
45097         this_arg_conv.inner = untag_ptr(this_arg);
45098         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45100         this_arg_conv.is_owned = false;
45101         LDKChannelFeatures features_conv;
45102         features_conv.inner = untag_ptr(features);
45103         features_conv.is_owned = ptr_is_owned(features);
45104         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
45105         features_conv = ChannelFeatures_clone(&features_conv);
45106         LDKPublicKey node_id_1_ref;
45107         CHECK((*env)->GetArrayLength(env, node_id_1) == 33);
45108         (*env)->GetByteArrayRegion(env, node_id_1, 0, 33, node_id_1_ref.compressed_form);
45109         LDKPublicKey node_id_2_ref;
45110         CHECK((*env)->GetArrayLength(env, node_id_2) == 33);
45111         (*env)->GetByteArrayRegion(env, node_id_2, 0, 33, node_id_2_ref.compressed_form);
45112         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
45113         *ret_conv = NetworkGraph_add_channel_from_partial_announcement(&this_arg_conv, short_channel_id, timestamp, features_conv, node_id_1_ref, node_id_2_ref);
45114         return tag_ptr(ret_conv, true);
45115 }
45116
45117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1channel_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
45118         LDKNetworkGraph this_arg_conv;
45119         this_arg_conv.inner = untag_ptr(this_arg);
45120         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45122         this_arg_conv.is_owned = false;
45123         NetworkGraph_channel_failed(&this_arg_conv, short_channel_id, is_permanent);
45124 }
45125
45126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1node_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
45127         LDKNetworkGraph this_arg_conv;
45128         this_arg_conv.inner = untag_ptr(this_arg);
45129         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45131         this_arg_conv.is_owned = false;
45132         LDKPublicKey _node_id_ref;
45133         CHECK((*env)->GetArrayLength(env, _node_id) == 33);
45134         (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form);
45135         NetworkGraph_node_failed(&this_arg_conv, _node_id_ref, is_permanent);
45136 }
45137
45138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
45139         LDKNetworkGraph this_arg_conv;
45140         this_arg_conv.inner = untag_ptr(this_arg);
45141         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45143         this_arg_conv.is_owned = false;
45144         NetworkGraph_remove_stale_channels(&this_arg_conv);
45145 }
45146
45147 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) {
45148         LDKNetworkGraph this_arg_conv;
45149         this_arg_conv.inner = untag_ptr(this_arg);
45150         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45152         this_arg_conv.is_owned = false;
45153         NetworkGraph_remove_stale_channels_with_time(&this_arg_conv, current_time_unix);
45154 }
45155
45156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
45157         LDKNetworkGraph this_arg_conv;
45158         this_arg_conv.inner = untag_ptr(this_arg);
45159         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45161         this_arg_conv.is_owned = false;
45162         LDKChannelUpdate msg_conv;
45163         msg_conv.inner = untag_ptr(msg);
45164         msg_conv.is_owned = ptr_is_owned(msg);
45165         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
45166         msg_conv.is_owned = false;
45167         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
45168         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
45169         return tag_ptr(ret_conv, true);
45170 }
45171
45172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
45173         LDKNetworkGraph this_arg_conv;
45174         this_arg_conv.inner = untag_ptr(this_arg);
45175         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45177         this_arg_conv.is_owned = false;
45178         LDKUnsignedChannelUpdate msg_conv;
45179         msg_conv.inner = untag_ptr(msg);
45180         msg_conv.is_owned = ptr_is_owned(msg);
45181         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
45182         msg_conv.is_owned = false;
45183         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
45184         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
45185         return tag_ptr(ret_conv, true);
45186 }
45187
45188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id) {
45189         LDKReadOnlyNetworkGraph this_arg_conv;
45190         this_arg_conv.inner = untag_ptr(this_arg);
45191         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45193         this_arg_conv.is_owned = false;
45194         LDKChannelInfo ret_var = ReadOnlyNetworkGraph_channel(&this_arg_conv, short_channel_id);
45195         int64_t ret_ref = 0;
45196         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45197         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45198         return ret_ref;
45199 }
45200
45201 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
45202         LDKReadOnlyNetworkGraph this_arg_conv;
45203         this_arg_conv.inner = untag_ptr(this_arg);
45204         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45206         this_arg_conv.is_owned = false;
45207         LDKCVec_u64Z ret_var = ReadOnlyNetworkGraph_list_channels(&this_arg_conv);
45208         int64_tArray ret_arr = NULL;
45209         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45210         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45211         for (size_t g = 0; g < ret_var.datalen; g++) {
45212                 int64_t ret_conv_6_conv = ret_var.data[g];
45213                 ret_arr_ptr[g] = ret_conv_6_conv;
45214         }
45215         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45216         FREE(ret_var.data);
45217         return ret_arr;
45218 }
45219
45220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1node(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
45221         LDKReadOnlyNetworkGraph this_arg_conv;
45222         this_arg_conv.inner = untag_ptr(this_arg);
45223         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45225         this_arg_conv.is_owned = false;
45226         LDKNodeId node_id_conv;
45227         node_id_conv.inner = untag_ptr(node_id);
45228         node_id_conv.is_owned = ptr_is_owned(node_id);
45229         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
45230         node_id_conv.is_owned = false;
45231         LDKNodeInfo ret_var = ReadOnlyNetworkGraph_node(&this_arg_conv, &node_id_conv);
45232         int64_t ret_ref = 0;
45233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45234         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45235         return ret_ref;
45236 }
45237
45238 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1nodes(JNIEnv *env, jclass clz, int64_t this_arg) {
45239         LDKReadOnlyNetworkGraph this_arg_conv;
45240         this_arg_conv.inner = untag_ptr(this_arg);
45241         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45243         this_arg_conv.is_owned = false;
45244         LDKCVec_NodeIdZ ret_var = ReadOnlyNetworkGraph_list_nodes(&this_arg_conv);
45245         int64_tArray ret_arr = NULL;
45246         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45247         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45248         for (size_t i = 0; i < ret_var.datalen; i++) {
45249                 LDKNodeId ret_conv_8_var = ret_var.data[i];
45250                 int64_t ret_conv_8_ref = 0;
45251                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_8_var);
45252                 ret_conv_8_ref = tag_ptr(ret_conv_8_var.inner, ret_conv_8_var.is_owned);
45253                 ret_arr_ptr[i] = ret_conv_8_ref;
45254         }
45255         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45256         FREE(ret_var.data);
45257         return ret_arr;
45258 }
45259
45260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
45261         LDKReadOnlyNetworkGraph this_arg_conv;
45262         this_arg_conv.inner = untag_ptr(this_arg);
45263         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45264         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45265         this_arg_conv.is_owned = false;
45266         LDKPublicKey pubkey_ref;
45267         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
45268         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
45269         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
45270         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
45271         int64_t ret_ref = tag_ptr(ret_copy, true);
45272         return ret_ref;
45273 }
45274
45275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45276         LDKRouteHop this_obj_conv;
45277         this_obj_conv.inner = untag_ptr(this_obj);
45278         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45280         RouteHop_free(this_obj_conv);
45281 }
45282
45283 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
45284         LDKRouteHop this_ptr_conv;
45285         this_ptr_conv.inner = untag_ptr(this_ptr);
45286         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45288         this_ptr_conv.is_owned = false;
45289         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
45290         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
45291         return ret_arr;
45292 }
45293
45294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
45295         LDKRouteHop this_ptr_conv;
45296         this_ptr_conv.inner = untag_ptr(this_ptr);
45297         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45299         this_ptr_conv.is_owned = false;
45300         LDKPublicKey val_ref;
45301         CHECK((*env)->GetArrayLength(env, val) == 33);
45302         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
45303         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
45304 }
45305
45306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
45307         LDKRouteHop this_ptr_conv;
45308         this_ptr_conv.inner = untag_ptr(this_ptr);
45309         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45311         this_ptr_conv.is_owned = false;
45312         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
45313         int64_t ret_ref = 0;
45314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45315         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45316         return ret_ref;
45317 }
45318
45319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45320         LDKRouteHop this_ptr_conv;
45321         this_ptr_conv.inner = untag_ptr(this_ptr);
45322         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45324         this_ptr_conv.is_owned = false;
45325         LDKNodeFeatures val_conv;
45326         val_conv.inner = untag_ptr(val);
45327         val_conv.is_owned = ptr_is_owned(val);
45328         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45329         val_conv = NodeFeatures_clone(&val_conv);
45330         RouteHop_set_node_features(&this_ptr_conv, val_conv);
45331 }
45332
45333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
45334         LDKRouteHop this_ptr_conv;
45335         this_ptr_conv.inner = untag_ptr(this_ptr);
45336         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45338         this_ptr_conv.is_owned = false;
45339         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
45340         return ret_conv;
45341 }
45342
45343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45344         LDKRouteHop this_ptr_conv;
45345         this_ptr_conv.inner = untag_ptr(this_ptr);
45346         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45347         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45348         this_ptr_conv.is_owned = false;
45349         RouteHop_set_short_channel_id(&this_ptr_conv, val);
45350 }
45351
45352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
45353         LDKRouteHop this_ptr_conv;
45354         this_ptr_conv.inner = untag_ptr(this_ptr);
45355         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45357         this_ptr_conv.is_owned = false;
45358         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
45359         int64_t ret_ref = 0;
45360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45361         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45362         return ret_ref;
45363 }
45364
45365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45366         LDKRouteHop this_ptr_conv;
45367         this_ptr_conv.inner = untag_ptr(this_ptr);
45368         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45370         this_ptr_conv.is_owned = false;
45371         LDKChannelFeatures val_conv;
45372         val_conv.inner = untag_ptr(val);
45373         val_conv.is_owned = ptr_is_owned(val);
45374         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45375         val_conv = ChannelFeatures_clone(&val_conv);
45376         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
45377 }
45378
45379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45380         LDKRouteHop this_ptr_conv;
45381         this_ptr_conv.inner = untag_ptr(this_ptr);
45382         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45384         this_ptr_conv.is_owned = false;
45385         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
45386         return ret_conv;
45387 }
45388
45389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45390         LDKRouteHop this_ptr_conv;
45391         this_ptr_conv.inner = untag_ptr(this_ptr);
45392         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45394         this_ptr_conv.is_owned = false;
45395         RouteHop_set_fee_msat(&this_ptr_conv, val);
45396 }
45397
45398 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
45399         LDKRouteHop this_ptr_conv;
45400         this_ptr_conv.inner = untag_ptr(this_ptr);
45401         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45403         this_ptr_conv.is_owned = false;
45404         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
45405         return ret_conv;
45406 }
45407
45408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
45409         LDKRouteHop this_ptr_conv;
45410         this_ptr_conv.inner = untag_ptr(this_ptr);
45411         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45413         this_ptr_conv.is_owned = false;
45414         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
45415 }
45416
45417 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) {
45418         LDKPublicKey pubkey_arg_ref;
45419         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
45420         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
45421         LDKNodeFeatures node_features_arg_conv;
45422         node_features_arg_conv.inner = untag_ptr(node_features_arg);
45423         node_features_arg_conv.is_owned = ptr_is_owned(node_features_arg);
45424         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
45425         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
45426         LDKChannelFeatures channel_features_arg_conv;
45427         channel_features_arg_conv.inner = untag_ptr(channel_features_arg);
45428         channel_features_arg_conv.is_owned = ptr_is_owned(channel_features_arg);
45429         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
45430         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
45431         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);
45432         int64_t ret_ref = 0;
45433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45434         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45435         return ret_ref;
45436 }
45437
45438 static inline uint64_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
45439         LDKRouteHop ret_var = RouteHop_clone(arg);
45440         int64_t ret_ref = 0;
45441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45442         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45443         return ret_ref;
45444 }
45445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45446         LDKRouteHop arg_conv;
45447         arg_conv.inner = untag_ptr(arg);
45448         arg_conv.is_owned = ptr_is_owned(arg);
45449         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45450         arg_conv.is_owned = false;
45451         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
45452         return ret_conv;
45453 }
45454
45455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45456         LDKRouteHop orig_conv;
45457         orig_conv.inner = untag_ptr(orig);
45458         orig_conv.is_owned = ptr_is_owned(orig);
45459         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45460         orig_conv.is_owned = false;
45461         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
45462         int64_t ret_ref = 0;
45463         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45464         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45465         return ret_ref;
45466 }
45467
45468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
45469         LDKRouteHop o_conv;
45470         o_conv.inner = untag_ptr(o);
45471         o_conv.is_owned = ptr_is_owned(o);
45472         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45473         o_conv.is_owned = false;
45474         int64_t ret_conv = RouteHop_hash(&o_conv);
45475         return ret_conv;
45476 }
45477
45478 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45479         LDKRouteHop a_conv;
45480         a_conv.inner = untag_ptr(a);
45481         a_conv.is_owned = ptr_is_owned(a);
45482         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45483         a_conv.is_owned = false;
45484         LDKRouteHop b_conv;
45485         b_conv.inner = untag_ptr(b);
45486         b_conv.is_owned = ptr_is_owned(b);
45487         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45488         b_conv.is_owned = false;
45489         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
45490         return ret_conv;
45491 }
45492
45493 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
45494         LDKRouteHop obj_conv;
45495         obj_conv.inner = untag_ptr(obj);
45496         obj_conv.is_owned = ptr_is_owned(obj);
45497         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45498         obj_conv.is_owned = false;
45499         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
45500         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45501         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45502         CVec_u8Z_free(ret_var);
45503         return ret_arr;
45504 }
45505
45506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45507         LDKu8slice ser_ref;
45508         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45509         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45510         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
45511         *ret_conv = RouteHop_read(ser_ref);
45512         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45513         return tag_ptr(ret_conv, true);
45514 }
45515
45516 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45517         LDKRoute this_obj_conv;
45518         this_obj_conv.inner = untag_ptr(this_obj);
45519         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45521         Route_free(this_obj_conv);
45522 }
45523
45524 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
45525         LDKRoute this_ptr_conv;
45526         this_ptr_conv.inner = untag_ptr(this_ptr);
45527         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45529         this_ptr_conv.is_owned = false;
45530         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
45531         jobjectArray ret_arr = NULL;
45532         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
45533         ;
45534         for (size_t m = 0; m < ret_var.datalen; m++) {
45535                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
45536                 int64_tArray ret_conv_12_arr = NULL;
45537                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
45538                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
45539                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
45540                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
45541                         int64_t ret_conv_12_conv_10_ref = 0;
45542                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
45543                         ret_conv_12_conv_10_ref = tag_ptr(ret_conv_12_conv_10_var.inner, ret_conv_12_conv_10_var.is_owned);
45544                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
45545                 }
45546                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
45547                 FREE(ret_conv_12_var.data);
45548                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
45549         }
45550         
45551         FREE(ret_var.data);
45552         return ret_arr;
45553 }
45554
45555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
45556         LDKRoute this_ptr_conv;
45557         this_ptr_conv.inner = untag_ptr(this_ptr);
45558         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45560         this_ptr_conv.is_owned = false;
45561         LDKCVec_CVec_RouteHopZZ val_constr;
45562         val_constr.datalen = (*env)->GetArrayLength(env, val);
45563         if (val_constr.datalen > 0)
45564                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
45565         else
45566                 val_constr.data = NULL;
45567         for (size_t m = 0; m < val_constr.datalen; m++) {
45568                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
45569                 LDKCVec_RouteHopZ val_conv_12_constr;
45570                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
45571                 if (val_conv_12_constr.datalen > 0)
45572                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
45573                 else
45574                         val_conv_12_constr.data = NULL;
45575                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
45576                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
45577                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
45578                         LDKRouteHop val_conv_12_conv_10_conv;
45579                         val_conv_12_conv_10_conv.inner = untag_ptr(val_conv_12_conv_10);
45580                         val_conv_12_conv_10_conv.is_owned = ptr_is_owned(val_conv_12_conv_10);
45581                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
45582                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
45583                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
45584                 }
45585                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
45586                 val_constr.data[m] = val_conv_12_constr;
45587         }
45588         Route_set_paths(&this_ptr_conv, val_constr);
45589 }
45590
45591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
45592         LDKRoute this_ptr_conv;
45593         this_ptr_conv.inner = untag_ptr(this_ptr);
45594         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45596         this_ptr_conv.is_owned = false;
45597         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
45598         int64_t ret_ref = 0;
45599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45600         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45601         return ret_ref;
45602 }
45603
45604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45605         LDKRoute this_ptr_conv;
45606         this_ptr_conv.inner = untag_ptr(this_ptr);
45607         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45609         this_ptr_conv.is_owned = false;
45610         LDKPaymentParameters val_conv;
45611         val_conv.inner = untag_ptr(val);
45612         val_conv.is_owned = ptr_is_owned(val);
45613         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45614         val_conv = PaymentParameters_clone(&val_conv);
45615         Route_set_payment_params(&this_ptr_conv, val_conv);
45616 }
45617
45618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payment_params_arg) {
45619         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
45620         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
45621         if (paths_arg_constr.datalen > 0)
45622                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
45623         else
45624                 paths_arg_constr.data = NULL;
45625         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
45626                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
45627                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
45628                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
45629                 if (paths_arg_conv_12_constr.datalen > 0)
45630                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
45631                 else
45632                         paths_arg_conv_12_constr.data = NULL;
45633                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
45634                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
45635                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
45636                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
45637                         paths_arg_conv_12_conv_10_conv.inner = untag_ptr(paths_arg_conv_12_conv_10);
45638                         paths_arg_conv_12_conv_10_conv.is_owned = ptr_is_owned(paths_arg_conv_12_conv_10);
45639                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
45640                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
45641                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
45642                 }
45643                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
45644                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
45645         }
45646         LDKPaymentParameters payment_params_arg_conv;
45647         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
45648         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
45649         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
45650         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
45651         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
45652         int64_t ret_ref = 0;
45653         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45654         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45655         return ret_ref;
45656 }
45657
45658 static inline uint64_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
45659         LDKRoute ret_var = Route_clone(arg);
45660         int64_t ret_ref = 0;
45661         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45662         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45663         return ret_ref;
45664 }
45665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45666         LDKRoute arg_conv;
45667         arg_conv.inner = untag_ptr(arg);
45668         arg_conv.is_owned = ptr_is_owned(arg);
45669         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45670         arg_conv.is_owned = false;
45671         int64_t ret_conv = Route_clone_ptr(&arg_conv);
45672         return ret_conv;
45673 }
45674
45675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45676         LDKRoute orig_conv;
45677         orig_conv.inner = untag_ptr(orig);
45678         orig_conv.is_owned = ptr_is_owned(orig);
45679         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45680         orig_conv.is_owned = false;
45681         LDKRoute ret_var = Route_clone(&orig_conv);
45682         int64_t ret_ref = 0;
45683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45684         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45685         return ret_ref;
45686 }
45687
45688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
45689         LDKRoute o_conv;
45690         o_conv.inner = untag_ptr(o);
45691         o_conv.is_owned = ptr_is_owned(o);
45692         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45693         o_conv.is_owned = false;
45694         int64_t ret_conv = Route_hash(&o_conv);
45695         return ret_conv;
45696 }
45697
45698 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45699         LDKRoute a_conv;
45700         a_conv.inner = untag_ptr(a);
45701         a_conv.is_owned = ptr_is_owned(a);
45702         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45703         a_conv.is_owned = false;
45704         LDKRoute b_conv;
45705         b_conv.inner = untag_ptr(b);
45706         b_conv.is_owned = ptr_is_owned(b);
45707         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45708         b_conv.is_owned = false;
45709         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
45710         return ret_conv;
45711 }
45712
45713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
45714         LDKRoute this_arg_conv;
45715         this_arg_conv.inner = untag_ptr(this_arg);
45716         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45718         this_arg_conv.is_owned = false;
45719         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
45720         return ret_conv;
45721 }
45722
45723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
45724         LDKRoute this_arg_conv;
45725         this_arg_conv.inner = untag_ptr(this_arg);
45726         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45728         this_arg_conv.is_owned = false;
45729         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
45730         return ret_conv;
45731 }
45732
45733 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
45734         LDKRoute obj_conv;
45735         obj_conv.inner = untag_ptr(obj);
45736         obj_conv.is_owned = ptr_is_owned(obj);
45737         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45738         obj_conv.is_owned = false;
45739         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
45740         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45741         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45742         CVec_u8Z_free(ret_var);
45743         return ret_arr;
45744 }
45745
45746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45747         LDKu8slice ser_ref;
45748         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45749         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45750         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
45751         *ret_conv = Route_read(ser_ref);
45752         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45753         return tag_ptr(ret_conv, true);
45754 }
45755
45756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45757         LDKRouteParameters this_obj_conv;
45758         this_obj_conv.inner = untag_ptr(this_obj);
45759         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45761         RouteParameters_free(this_obj_conv);
45762 }
45763
45764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
45765         LDKRouteParameters this_ptr_conv;
45766         this_ptr_conv.inner = untag_ptr(this_ptr);
45767         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45769         this_ptr_conv.is_owned = false;
45770         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
45771         int64_t ret_ref = 0;
45772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45773         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45774         return ret_ref;
45775 }
45776
45777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45778         LDKRouteParameters this_ptr_conv;
45779         this_ptr_conv.inner = untag_ptr(this_ptr);
45780         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45782         this_ptr_conv.is_owned = false;
45783         LDKPaymentParameters val_conv;
45784         val_conv.inner = untag_ptr(val);
45785         val_conv.is_owned = ptr_is_owned(val);
45786         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45787         val_conv = PaymentParameters_clone(&val_conv);
45788         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
45789 }
45790
45791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
45792         LDKRouteParameters this_ptr_conv;
45793         this_ptr_conv.inner = untag_ptr(this_ptr);
45794         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45796         this_ptr_conv.is_owned = false;
45797         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
45798         return ret_conv;
45799 }
45800
45801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45802         LDKRouteParameters this_ptr_conv;
45803         this_ptr_conv.inner = untag_ptr(this_ptr);
45804         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45806         this_ptr_conv.is_owned = false;
45807         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
45808 }
45809
45810 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
45811         LDKRouteParameters this_ptr_conv;
45812         this_ptr_conv.inner = untag_ptr(this_ptr);
45813         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45815         this_ptr_conv.is_owned = false;
45816         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
45817         return ret_conv;
45818 }
45819
45820 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) {
45821         LDKRouteParameters this_ptr_conv;
45822         this_ptr_conv.inner = untag_ptr(this_ptr);
45823         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45825         this_ptr_conv.is_owned = false;
45826         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
45827 }
45828
45829 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) {
45830         LDKPaymentParameters payment_params_arg_conv;
45831         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
45832         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
45833         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
45834         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
45835         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
45836         int64_t ret_ref = 0;
45837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45838         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45839         return ret_ref;
45840 }
45841
45842 static inline uint64_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
45843         LDKRouteParameters ret_var = RouteParameters_clone(arg);
45844         int64_t ret_ref = 0;
45845         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45846         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45847         return ret_ref;
45848 }
45849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45850         LDKRouteParameters arg_conv;
45851         arg_conv.inner = untag_ptr(arg);
45852         arg_conv.is_owned = ptr_is_owned(arg);
45853         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45854         arg_conv.is_owned = false;
45855         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
45856         return ret_conv;
45857 }
45858
45859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45860         LDKRouteParameters orig_conv;
45861         orig_conv.inner = untag_ptr(orig);
45862         orig_conv.is_owned = ptr_is_owned(orig);
45863         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45864         orig_conv.is_owned = false;
45865         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
45866         int64_t ret_ref = 0;
45867         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45868         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45869         return ret_ref;
45870 }
45871
45872 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
45873         LDKRouteParameters obj_conv;
45874         obj_conv.inner = untag_ptr(obj);
45875         obj_conv.is_owned = ptr_is_owned(obj);
45876         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45877         obj_conv.is_owned = false;
45878         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
45879         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45880         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45881         CVec_u8Z_free(ret_var);
45882         return ret_arr;
45883 }
45884
45885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45886         LDKu8slice ser_ref;
45887         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45888         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45889         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
45890         *ret_conv = RouteParameters_read(ser_ref);
45891         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45892         return tag_ptr(ret_conv, true);
45893 }
45894
45895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45896         LDKPaymentParameters this_obj_conv;
45897         this_obj_conv.inner = untag_ptr(this_obj);
45898         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45900         PaymentParameters_free(this_obj_conv);
45901 }
45902
45903 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
45904         LDKPaymentParameters this_ptr_conv;
45905         this_ptr_conv.inner = untag_ptr(this_ptr);
45906         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45908         this_ptr_conv.is_owned = false;
45909         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
45910         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
45911         return ret_arr;
45912 }
45913
45914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
45915         LDKPaymentParameters this_ptr_conv;
45916         this_ptr_conv.inner = untag_ptr(this_ptr);
45917         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45919         this_ptr_conv.is_owned = false;
45920         LDKPublicKey val_ref;
45921         CHECK((*env)->GetArrayLength(env, val) == 33);
45922         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
45923         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
45924 }
45925
45926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
45927         LDKPaymentParameters this_ptr_conv;
45928         this_ptr_conv.inner = untag_ptr(this_ptr);
45929         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45931         this_ptr_conv.is_owned = false;
45932         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
45933         int64_t ret_ref = 0;
45934         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45935         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45936         return ret_ref;
45937 }
45938
45939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
45940         LDKPaymentParameters this_ptr_conv;
45941         this_ptr_conv.inner = untag_ptr(this_ptr);
45942         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45944         this_ptr_conv.is_owned = false;
45945         LDKInvoiceFeatures val_conv;
45946         val_conv.inner = untag_ptr(val);
45947         val_conv.is_owned = ptr_is_owned(val);
45948         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
45949         val_conv = InvoiceFeatures_clone(&val_conv);
45950         PaymentParameters_set_features(&this_ptr_conv, val_conv);
45951 }
45952
45953 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
45954         LDKPaymentParameters this_ptr_conv;
45955         this_ptr_conv.inner = untag_ptr(this_ptr);
45956         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45958         this_ptr_conv.is_owned = false;
45959         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
45960         int64_tArray ret_arr = NULL;
45961         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
45962         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
45963         for (size_t l = 0; l < ret_var.datalen; l++) {
45964                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
45965                 int64_t ret_conv_11_ref = 0;
45966                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
45967                 ret_conv_11_ref = tag_ptr(ret_conv_11_var.inner, ret_conv_11_var.is_owned);
45968                 ret_arr_ptr[l] = ret_conv_11_ref;
45969         }
45970         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
45971         FREE(ret_var.data);
45972         return ret_arr;
45973 }
45974
45975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
45976         LDKPaymentParameters this_ptr_conv;
45977         this_ptr_conv.inner = untag_ptr(this_ptr);
45978         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45980         this_ptr_conv.is_owned = false;
45981         LDKCVec_RouteHintZ val_constr;
45982         val_constr.datalen = (*env)->GetArrayLength(env, val);
45983         if (val_constr.datalen > 0)
45984                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
45985         else
45986                 val_constr.data = NULL;
45987         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
45988         for (size_t l = 0; l < val_constr.datalen; l++) {
45989                 int64_t val_conv_11 = val_vals[l];
45990                 LDKRouteHint val_conv_11_conv;
45991                 val_conv_11_conv.inner = untag_ptr(val_conv_11);
45992                 val_conv_11_conv.is_owned = ptr_is_owned(val_conv_11);
45993                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
45994                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
45995                 val_constr.data[l] = val_conv_11_conv;
45996         }
45997         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
45998         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
45999 }
46000
46001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
46002         LDKPaymentParameters this_ptr_conv;
46003         this_ptr_conv.inner = untag_ptr(this_ptr);
46004         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46006         this_ptr_conv.is_owned = false;
46007         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
46008         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
46009         int64_t ret_ref = tag_ptr(ret_copy, true);
46010         return ret_ref;
46011 }
46012
46013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46014         LDKPaymentParameters this_ptr_conv;
46015         this_ptr_conv.inner = untag_ptr(this_ptr);
46016         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46018         this_ptr_conv.is_owned = false;
46019         void* val_ptr = untag_ptr(val);
46020         CHECK_ACCESS(val_ptr);
46021         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
46022         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
46023         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
46024 }
46025
46026 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
46027         LDKPaymentParameters this_ptr_conv;
46028         this_ptr_conv.inner = untag_ptr(this_ptr);
46029         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46031         this_ptr_conv.is_owned = false;
46032         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
46033         return ret_conv;
46034 }
46035
46036 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) {
46037         LDKPaymentParameters this_ptr_conv;
46038         this_ptr_conv.inner = untag_ptr(this_ptr);
46039         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46041         this_ptr_conv.is_owned = false;
46042         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
46043 }
46044
46045 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr) {
46046         LDKPaymentParameters this_ptr_conv;
46047         this_ptr_conv.inner = untag_ptr(this_ptr);
46048         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46050         this_ptr_conv.is_owned = false;
46051         int8_t ret_conv = PaymentParameters_get_max_path_count(&this_ptr_conv);
46052         return ret_conv;
46053 }
46054
46055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
46056         LDKPaymentParameters this_ptr_conv;
46057         this_ptr_conv.inner = untag_ptr(this_ptr);
46058         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46060         this_ptr_conv.is_owned = false;
46061         PaymentParameters_set_max_path_count(&this_ptr_conv, val);
46062 }
46063
46064 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1channel_1saturation_1power_1of_1half(JNIEnv *env, jclass clz, int64_t this_ptr) {
46065         LDKPaymentParameters this_ptr_conv;
46066         this_ptr_conv.inner = untag_ptr(this_ptr);
46067         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46069         this_ptr_conv.is_owned = false;
46070         int8_t ret_conv = PaymentParameters_get_max_channel_saturation_power_of_half(&this_ptr_conv);
46071         return ret_conv;
46072 }
46073
46074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1channel_1saturation_1power_1of_1half(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
46075         LDKPaymentParameters this_ptr_conv;
46076         this_ptr_conv.inner = untag_ptr(this_ptr);
46077         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46079         this_ptr_conv.is_owned = false;
46080         PaymentParameters_set_max_channel_saturation_power_of_half(&this_ptr_conv, val);
46081 }
46082
46083 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
46084         LDKPaymentParameters this_ptr_conv;
46085         this_ptr_conv.inner = untag_ptr(this_ptr);
46086         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46088         this_ptr_conv.is_owned = false;
46089         LDKCVec_u64Z ret_var = PaymentParameters_get_previously_failed_channels(&this_ptr_conv);
46090         int64_tArray ret_arr = NULL;
46091         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
46092         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
46093         for (size_t g = 0; g < ret_var.datalen; g++) {
46094                 int64_t ret_conv_6_conv = ret_var.data[g];
46095                 ret_arr_ptr[g] = ret_conv_6_conv;
46096         }
46097         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
46098         FREE(ret_var.data);
46099         return ret_arr;
46100 }
46101
46102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
46103         LDKPaymentParameters this_ptr_conv;
46104         this_ptr_conv.inner = untag_ptr(this_ptr);
46105         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46107         this_ptr_conv.is_owned = false;
46108         LDKCVec_u64Z val_constr;
46109         val_constr.datalen = (*env)->GetArrayLength(env, val);
46110         if (val_constr.datalen > 0)
46111                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
46112         else
46113                 val_constr.data = NULL;
46114         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
46115         for (size_t g = 0; g < val_constr.datalen; g++) {
46116                 int64_t val_conv_6 = val_vals[g];
46117                 val_constr.data[g] = val_conv_6;
46118         }
46119         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
46120         PaymentParameters_set_previously_failed_channels(&this_ptr_conv, val_constr);
46121 }
46122
46123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1new(JNIEnv *env, jclass clz, int8_tArray payee_pubkey_arg, int64_t features_arg, int64_tArray route_hints_arg, int64_t expiry_time_arg, int32_t max_total_cltv_expiry_delta_arg, int8_t max_path_count_arg, int8_t max_channel_saturation_power_of_half_arg, int64_tArray previously_failed_channels_arg) {
46124         LDKPublicKey payee_pubkey_arg_ref;
46125         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
46126         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
46127         LDKInvoiceFeatures features_arg_conv;
46128         features_arg_conv.inner = untag_ptr(features_arg);
46129         features_arg_conv.is_owned = ptr_is_owned(features_arg);
46130         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
46131         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
46132         LDKCVec_RouteHintZ route_hints_arg_constr;
46133         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
46134         if (route_hints_arg_constr.datalen > 0)
46135                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
46136         else
46137                 route_hints_arg_constr.data = NULL;
46138         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
46139         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
46140                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
46141                 LDKRouteHint route_hints_arg_conv_11_conv;
46142                 route_hints_arg_conv_11_conv.inner = untag_ptr(route_hints_arg_conv_11);
46143                 route_hints_arg_conv_11_conv.is_owned = ptr_is_owned(route_hints_arg_conv_11);
46144                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
46145                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
46146                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
46147         }
46148         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
46149         void* expiry_time_arg_ptr = untag_ptr(expiry_time_arg);
46150         CHECK_ACCESS(expiry_time_arg_ptr);
46151         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
46152         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(expiry_time_arg));
46153         LDKCVec_u64Z previously_failed_channels_arg_constr;
46154         previously_failed_channels_arg_constr.datalen = (*env)->GetArrayLength(env, previously_failed_channels_arg);
46155         if (previously_failed_channels_arg_constr.datalen > 0)
46156                 previously_failed_channels_arg_constr.data = MALLOC(previously_failed_channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
46157         else
46158                 previously_failed_channels_arg_constr.data = NULL;
46159         int64_t* previously_failed_channels_arg_vals = (*env)->GetLongArrayElements (env, previously_failed_channels_arg, NULL);
46160         for (size_t g = 0; g < previously_failed_channels_arg_constr.datalen; g++) {
46161                 int64_t previously_failed_channels_arg_conv_6 = previously_failed_channels_arg_vals[g];
46162                 previously_failed_channels_arg_constr.data[g] = previously_failed_channels_arg_conv_6;
46163         }
46164         (*env)->ReleaseLongArrayElements(env, previously_failed_channels_arg, previously_failed_channels_arg_vals, 0);
46165         LDKPaymentParameters ret_var = PaymentParameters_new(payee_pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv, max_total_cltv_expiry_delta_arg, max_path_count_arg, max_channel_saturation_power_of_half_arg, previously_failed_channels_arg_constr);
46166         int64_t ret_ref = 0;
46167         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46168         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46169         return ret_ref;
46170 }
46171
46172 static inline uint64_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
46173         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
46174         int64_t ret_ref = 0;
46175         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46176         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46177         return ret_ref;
46178 }
46179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46180         LDKPaymentParameters arg_conv;
46181         arg_conv.inner = untag_ptr(arg);
46182         arg_conv.is_owned = ptr_is_owned(arg);
46183         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46184         arg_conv.is_owned = false;
46185         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
46186         return ret_conv;
46187 }
46188
46189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46190         LDKPaymentParameters orig_conv;
46191         orig_conv.inner = untag_ptr(orig);
46192         orig_conv.is_owned = ptr_is_owned(orig);
46193         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46194         orig_conv.is_owned = false;
46195         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
46196         int64_t ret_ref = 0;
46197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46198         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46199         return ret_ref;
46200 }
46201
46202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
46203         LDKPaymentParameters o_conv;
46204         o_conv.inner = untag_ptr(o);
46205         o_conv.is_owned = ptr_is_owned(o);
46206         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46207         o_conv.is_owned = false;
46208         int64_t ret_conv = PaymentParameters_hash(&o_conv);
46209         return ret_conv;
46210 }
46211
46212 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46213         LDKPaymentParameters a_conv;
46214         a_conv.inner = untag_ptr(a);
46215         a_conv.is_owned = ptr_is_owned(a);
46216         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46217         a_conv.is_owned = false;
46218         LDKPaymentParameters b_conv;
46219         b_conv.inner = untag_ptr(b);
46220         b_conv.is_owned = ptr_is_owned(b);
46221         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46222         b_conv.is_owned = false;
46223         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
46224         return ret_conv;
46225 }
46226
46227 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
46228         LDKPaymentParameters obj_conv;
46229         obj_conv.inner = untag_ptr(obj);
46230         obj_conv.is_owned = ptr_is_owned(obj);
46231         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46232         obj_conv.is_owned = false;
46233         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
46234         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46235         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46236         CVec_u8Z_free(ret_var);
46237         return ret_arr;
46238 }
46239
46240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46241         LDKu8slice ser_ref;
46242         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46243         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46244         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
46245         *ret_conv = PaymentParameters_read(ser_ref);
46246         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46247         return tag_ptr(ret_conv, true);
46248 }
46249
46250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
46251         LDKPublicKey payee_pubkey_ref;
46252         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
46253         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
46254         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
46255         int64_t ret_ref = 0;
46256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46257         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46258         return ret_ref;
46259 }
46260
46261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
46262         LDKPublicKey payee_pubkey_ref;
46263         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
46264         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
46265         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
46266         int64_t ret_ref = 0;
46267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46268         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46269         return ret_ref;
46270 }
46271
46272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46273         LDKRouteHint this_obj_conv;
46274         this_obj_conv.inner = untag_ptr(this_obj);
46275         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46277         RouteHint_free(this_obj_conv);
46278 }
46279
46280 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
46281         LDKRouteHint this_ptr_conv;
46282         this_ptr_conv.inner = untag_ptr(this_ptr);
46283         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46285         this_ptr_conv.is_owned = false;
46286         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
46287         int64_tArray ret_arr = NULL;
46288         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
46289         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
46290         for (size_t o = 0; o < ret_var.datalen; o++) {
46291                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
46292                 int64_t ret_conv_14_ref = 0;
46293                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
46294                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
46295                 ret_arr_ptr[o] = ret_conv_14_ref;
46296         }
46297         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
46298         FREE(ret_var.data);
46299         return ret_arr;
46300 }
46301
46302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
46303         LDKRouteHint this_ptr_conv;
46304         this_ptr_conv.inner = untag_ptr(this_ptr);
46305         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46307         this_ptr_conv.is_owned = false;
46308         LDKCVec_RouteHintHopZ val_constr;
46309         val_constr.datalen = (*env)->GetArrayLength(env, val);
46310         if (val_constr.datalen > 0)
46311                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
46312         else
46313                 val_constr.data = NULL;
46314         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
46315         for (size_t o = 0; o < val_constr.datalen; o++) {
46316                 int64_t val_conv_14 = val_vals[o];
46317                 LDKRouteHintHop val_conv_14_conv;
46318                 val_conv_14_conv.inner = untag_ptr(val_conv_14);
46319                 val_conv_14_conv.is_owned = ptr_is_owned(val_conv_14);
46320                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
46321                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
46322                 val_constr.data[o] = val_conv_14_conv;
46323         }
46324         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
46325         RouteHint_set_a(&this_ptr_conv, val_constr);
46326 }
46327
46328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
46329         LDKCVec_RouteHintHopZ a_arg_constr;
46330         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
46331         if (a_arg_constr.datalen > 0)
46332                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
46333         else
46334                 a_arg_constr.data = NULL;
46335         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
46336         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
46337                 int64_t a_arg_conv_14 = a_arg_vals[o];
46338                 LDKRouteHintHop a_arg_conv_14_conv;
46339                 a_arg_conv_14_conv.inner = untag_ptr(a_arg_conv_14);
46340                 a_arg_conv_14_conv.is_owned = ptr_is_owned(a_arg_conv_14);
46341                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
46342                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
46343                 a_arg_constr.data[o] = a_arg_conv_14_conv;
46344         }
46345         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
46346         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
46347         int64_t ret_ref = 0;
46348         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46349         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46350         return ret_ref;
46351 }
46352
46353 static inline uint64_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
46354         LDKRouteHint ret_var = RouteHint_clone(arg);
46355         int64_t ret_ref = 0;
46356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46357         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46358         return ret_ref;
46359 }
46360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46361         LDKRouteHint arg_conv;
46362         arg_conv.inner = untag_ptr(arg);
46363         arg_conv.is_owned = ptr_is_owned(arg);
46364         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46365         arg_conv.is_owned = false;
46366         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
46367         return ret_conv;
46368 }
46369
46370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46371         LDKRouteHint orig_conv;
46372         orig_conv.inner = untag_ptr(orig);
46373         orig_conv.is_owned = ptr_is_owned(orig);
46374         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46375         orig_conv.is_owned = false;
46376         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
46377         int64_t ret_ref = 0;
46378         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46379         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46380         return ret_ref;
46381 }
46382
46383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
46384         LDKRouteHint o_conv;
46385         o_conv.inner = untag_ptr(o);
46386         o_conv.is_owned = ptr_is_owned(o);
46387         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46388         o_conv.is_owned = false;
46389         int64_t ret_conv = RouteHint_hash(&o_conv);
46390         return ret_conv;
46391 }
46392
46393 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46394         LDKRouteHint a_conv;
46395         a_conv.inner = untag_ptr(a);
46396         a_conv.is_owned = ptr_is_owned(a);
46397         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46398         a_conv.is_owned = false;
46399         LDKRouteHint b_conv;
46400         b_conv.inner = untag_ptr(b);
46401         b_conv.is_owned = ptr_is_owned(b);
46402         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46403         b_conv.is_owned = false;
46404         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
46405         return ret_conv;
46406 }
46407
46408 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
46409         LDKRouteHint obj_conv;
46410         obj_conv.inner = untag_ptr(obj);
46411         obj_conv.is_owned = ptr_is_owned(obj);
46412         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46413         obj_conv.is_owned = false;
46414         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
46415         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46416         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46417         CVec_u8Z_free(ret_var);
46418         return ret_arr;
46419 }
46420
46421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46422         LDKu8slice ser_ref;
46423         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46424         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46425         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
46426         *ret_conv = RouteHint_read(ser_ref);
46427         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46428         return tag_ptr(ret_conv, true);
46429 }
46430
46431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46432         LDKRouteHintHop this_obj_conv;
46433         this_obj_conv.inner = untag_ptr(this_obj);
46434         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46436         RouteHintHop_free(this_obj_conv);
46437 }
46438
46439 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
46440         LDKRouteHintHop this_ptr_conv;
46441         this_ptr_conv.inner = untag_ptr(this_ptr);
46442         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46444         this_ptr_conv.is_owned = false;
46445         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
46446         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
46447         return ret_arr;
46448 }
46449
46450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
46451         LDKRouteHintHop this_ptr_conv;
46452         this_ptr_conv.inner = untag_ptr(this_ptr);
46453         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46455         this_ptr_conv.is_owned = false;
46456         LDKPublicKey val_ref;
46457         CHECK((*env)->GetArrayLength(env, val) == 33);
46458         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
46459         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
46460 }
46461
46462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
46463         LDKRouteHintHop this_ptr_conv;
46464         this_ptr_conv.inner = untag_ptr(this_ptr);
46465         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46467         this_ptr_conv.is_owned = false;
46468         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
46469         return ret_conv;
46470 }
46471
46472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46473         LDKRouteHintHop this_ptr_conv;
46474         this_ptr_conv.inner = untag_ptr(this_ptr);
46475         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46477         this_ptr_conv.is_owned = false;
46478         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
46479 }
46480
46481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
46482         LDKRouteHintHop this_ptr_conv;
46483         this_ptr_conv.inner = untag_ptr(this_ptr);
46484         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46486         this_ptr_conv.is_owned = false;
46487         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
46488         int64_t ret_ref = 0;
46489         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46490         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46491         return ret_ref;
46492 }
46493
46494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46495         LDKRouteHintHop this_ptr_conv;
46496         this_ptr_conv.inner = untag_ptr(this_ptr);
46497         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46499         this_ptr_conv.is_owned = false;
46500         LDKRoutingFees val_conv;
46501         val_conv.inner = untag_ptr(val);
46502         val_conv.is_owned = ptr_is_owned(val);
46503         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46504         val_conv = RoutingFees_clone(&val_conv);
46505         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
46506 }
46507
46508 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
46509         LDKRouteHintHop this_ptr_conv;
46510         this_ptr_conv.inner = untag_ptr(this_ptr);
46511         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46513         this_ptr_conv.is_owned = false;
46514         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
46515         return ret_conv;
46516 }
46517
46518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
46519         LDKRouteHintHop this_ptr_conv;
46520         this_ptr_conv.inner = untag_ptr(this_ptr);
46521         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46523         this_ptr_conv.is_owned = false;
46524         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
46525 }
46526
46527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46528         LDKRouteHintHop this_ptr_conv;
46529         this_ptr_conv.inner = untag_ptr(this_ptr);
46530         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46532         this_ptr_conv.is_owned = false;
46533         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
46534         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
46535         int64_t ret_ref = tag_ptr(ret_copy, true);
46536         return ret_ref;
46537 }
46538
46539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46540         LDKRouteHintHop this_ptr_conv;
46541         this_ptr_conv.inner = untag_ptr(this_ptr);
46542         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46544         this_ptr_conv.is_owned = false;
46545         void* val_ptr = untag_ptr(val);
46546         CHECK_ACCESS(val_ptr);
46547         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
46548         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
46549         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
46550 }
46551
46552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46553         LDKRouteHintHop this_ptr_conv;
46554         this_ptr_conv.inner = untag_ptr(this_ptr);
46555         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46557         this_ptr_conv.is_owned = false;
46558         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
46559         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
46560         int64_t ret_ref = tag_ptr(ret_copy, true);
46561         return ret_ref;
46562 }
46563
46564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46565         LDKRouteHintHop this_ptr_conv;
46566         this_ptr_conv.inner = untag_ptr(this_ptr);
46567         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46569         this_ptr_conv.is_owned = false;
46570         void* val_ptr = untag_ptr(val);
46571         CHECK_ACCESS(val_ptr);
46572         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
46573         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
46574         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
46575 }
46576
46577 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) {
46578         LDKPublicKey src_node_id_arg_ref;
46579         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
46580         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
46581         LDKRoutingFees fees_arg_conv;
46582         fees_arg_conv.inner = untag_ptr(fees_arg);
46583         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
46584         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
46585         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
46586         void* htlc_minimum_msat_arg_ptr = untag_ptr(htlc_minimum_msat_arg);
46587         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
46588         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
46589         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_minimum_msat_arg));
46590         void* htlc_maximum_msat_arg_ptr = untag_ptr(htlc_maximum_msat_arg);
46591         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
46592         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
46593         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_maximum_msat_arg));
46594         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);
46595         int64_t ret_ref = 0;
46596         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46597         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46598         return ret_ref;
46599 }
46600
46601 static inline uint64_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
46602         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
46603         int64_t ret_ref = 0;
46604         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46605         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46606         return ret_ref;
46607 }
46608 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46609         LDKRouteHintHop arg_conv;
46610         arg_conv.inner = untag_ptr(arg);
46611         arg_conv.is_owned = ptr_is_owned(arg);
46612         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46613         arg_conv.is_owned = false;
46614         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
46615         return ret_conv;
46616 }
46617
46618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46619         LDKRouteHintHop orig_conv;
46620         orig_conv.inner = untag_ptr(orig);
46621         orig_conv.is_owned = ptr_is_owned(orig);
46622         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46623         orig_conv.is_owned = false;
46624         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
46625         int64_t ret_ref = 0;
46626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46627         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46628         return ret_ref;
46629 }
46630
46631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
46632         LDKRouteHintHop o_conv;
46633         o_conv.inner = untag_ptr(o);
46634         o_conv.is_owned = ptr_is_owned(o);
46635         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46636         o_conv.is_owned = false;
46637         int64_t ret_conv = RouteHintHop_hash(&o_conv);
46638         return ret_conv;
46639 }
46640
46641 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46642         LDKRouteHintHop a_conv;
46643         a_conv.inner = untag_ptr(a);
46644         a_conv.is_owned = ptr_is_owned(a);
46645         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46646         a_conv.is_owned = false;
46647         LDKRouteHintHop b_conv;
46648         b_conv.inner = untag_ptr(b);
46649         b_conv.is_owned = ptr_is_owned(b);
46650         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46651         b_conv.is_owned = false;
46652         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
46653         return ret_conv;
46654 }
46655
46656 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
46657         LDKRouteHintHop obj_conv;
46658         obj_conv.inner = untag_ptr(obj);
46659         obj_conv.is_owned = ptr_is_owned(obj);
46660         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46661         obj_conv.is_owned = false;
46662         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
46663         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46664         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46665         CVec_u8Z_free(ret_var);
46666         return ret_arr;
46667 }
46668
46669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46670         LDKu8slice ser_ref;
46671         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46672         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46673         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
46674         *ret_conv = RouteHintHop_read(ser_ref);
46675         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46676         return tag_ptr(ret_conv, true);
46677 }
46678
46679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_find_1route(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, int64_t route_params, int64_t network_graph, int64_tArray first_hops, int64_t logger, int64_t scorer, int8_tArray random_seed_bytes) {
46680         LDKPublicKey our_node_pubkey_ref;
46681         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
46682         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
46683         LDKRouteParameters route_params_conv;
46684         route_params_conv.inner = untag_ptr(route_params);
46685         route_params_conv.is_owned = ptr_is_owned(route_params);
46686         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
46687         route_params_conv.is_owned = false;
46688         LDKNetworkGraph network_graph_conv;
46689         network_graph_conv.inner = untag_ptr(network_graph);
46690         network_graph_conv.is_owned = ptr_is_owned(network_graph);
46691         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
46692         network_graph_conv.is_owned = false;
46693         LDKCVec_ChannelDetailsZ first_hops_constr;
46694         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
46695         if (first_hops != NULL) {
46696                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
46697                 if (first_hops_constr.datalen > 0)
46698                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
46699                 else
46700                         first_hops_constr.data = NULL;
46701                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
46702                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
46703                         int64_t first_hops_conv_16 = first_hops_vals[q];
46704                         LDKChannelDetails first_hops_conv_16_conv;
46705                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
46706                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
46707                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
46708                         first_hops_conv_16_conv.is_owned = false;
46709                         first_hops_constr.data[q] = first_hops_conv_16_conv;
46710                 }
46711                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
46712                 first_hops_ptr = &first_hops_constr;
46713         }
46714         void* logger_ptr = untag_ptr(logger);
46715         CHECK_ACCESS(logger_ptr);
46716         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46717         if (logger_conv.free == LDKLogger_JCalls_free) {
46718                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46719                 LDKLogger_JCalls_cloned(&logger_conv);
46720         }
46721         void* scorer_ptr = untag_ptr(scorer);
46722         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
46723         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
46724         unsigned char random_seed_bytes_arr[32];
46725         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
46726         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
46727         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
46728         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
46729         *ret_conv = find_route(our_node_pubkey_ref, &route_params_conv, &network_graph_conv, first_hops_ptr, logger_conv, scorer_conv, random_seed_bytes_ref);
46730         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
46731         return tag_ptr(ret_conv, true);
46732 }
46733
46734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_build_1route_1from_1hops(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, jobjectArray hops, int64_t route_params, int64_t network_graph, int64_t logger, int8_tArray random_seed_bytes) {
46735         LDKPublicKey our_node_pubkey_ref;
46736         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
46737         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
46738         LDKCVec_PublicKeyZ hops_constr;
46739         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
46740         if (hops_constr.datalen > 0)
46741                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
46742         else
46743                 hops_constr.data = NULL;
46744         for (size_t i = 0; i < hops_constr.datalen; i++) {
46745                 int8_tArray hops_conv_8 = (*env)->GetObjectArrayElement(env, hops, i);
46746                 LDKPublicKey hops_conv_8_ref;
46747                 CHECK((*env)->GetArrayLength(env, hops_conv_8) == 33);
46748                 (*env)->GetByteArrayRegion(env, hops_conv_8, 0, 33, hops_conv_8_ref.compressed_form);
46749                 hops_constr.data[i] = hops_conv_8_ref;
46750         }
46751         LDKRouteParameters route_params_conv;
46752         route_params_conv.inner = untag_ptr(route_params);
46753         route_params_conv.is_owned = ptr_is_owned(route_params);
46754         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
46755         route_params_conv.is_owned = false;
46756         LDKNetworkGraph network_graph_conv;
46757         network_graph_conv.inner = untag_ptr(network_graph);
46758         network_graph_conv.is_owned = ptr_is_owned(network_graph);
46759         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
46760         network_graph_conv.is_owned = false;
46761         void* logger_ptr = untag_ptr(logger);
46762         CHECK_ACCESS(logger_ptr);
46763         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46764         if (logger_conv.free == LDKLogger_JCalls_free) {
46765                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46766                 LDKLogger_JCalls_cloned(&logger_conv);
46767         }
46768         unsigned char random_seed_bytes_arr[32];
46769         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
46770         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
46771         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
46772         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
46773         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
46774         return tag_ptr(ret_conv, true);
46775 }
46776
46777 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46778         if (!ptr_is_owned(this_ptr)) return;
46779         void* this_ptr_ptr = untag_ptr(this_ptr);
46780         CHECK_ACCESS(this_ptr_ptr);
46781         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
46782         FREE(untag_ptr(this_ptr));
46783         Score_free(this_ptr_conv);
46784 }
46785
46786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46787         if (!ptr_is_owned(this_ptr)) return;
46788         void* this_ptr_ptr = untag_ptr(this_ptr);
46789         CHECK_ACCESS(this_ptr_ptr);
46790         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
46791         FREE(untag_ptr(this_ptr));
46792         LockableScore_free(this_ptr_conv);
46793 }
46794
46795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WriteableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46796         if (!ptr_is_owned(this_ptr)) return;
46797         void* this_ptr_ptr = untag_ptr(this_ptr);
46798         CHECK_ACCESS(this_ptr_ptr);
46799         LDKWriteableScore this_ptr_conv = *(LDKWriteableScore*)(this_ptr_ptr);
46800         FREE(untag_ptr(this_ptr));
46801         WriteableScore_free(this_ptr_conv);
46802 }
46803
46804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46805         LDKMultiThreadedLockableScore this_obj_conv;
46806         this_obj_conv.inner = untag_ptr(this_obj);
46807         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46809         MultiThreadedLockableScore_free(this_obj_conv);
46810 }
46811
46812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46813         LDKMultiThreadedScoreLock this_obj_conv;
46814         this_obj_conv.inner = untag_ptr(this_obj);
46815         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46817         MultiThreadedScoreLock_free(this_obj_conv);
46818 }
46819
46820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
46821         LDKMultiThreadedScoreLock this_arg_conv;
46822         this_arg_conv.inner = untag_ptr(this_arg);
46823         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46824         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46825         this_arg_conv.is_owned = false;
46826         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
46827         *ret_ret = MultiThreadedScoreLock_as_Score(&this_arg_conv);
46828         return tag_ptr(ret_ret, true);
46829 }
46830
46831 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1write(JNIEnv *env, jclass clz, int64_t obj) {
46832         LDKMultiThreadedScoreLock obj_conv;
46833         obj_conv.inner = untag_ptr(obj);
46834         obj_conv.is_owned = ptr_is_owned(obj);
46835         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46836         obj_conv.is_owned = false;
46837         LDKCVec_u8Z ret_var = MultiThreadedScoreLock_write(&obj_conv);
46838         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46839         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46840         CVec_u8Z_free(ret_var);
46841         return ret_arr;
46842 }
46843
46844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1as_1LockableScore(JNIEnv *env, jclass clz, int64_t this_arg) {
46845         LDKMultiThreadedLockableScore this_arg_conv;
46846         this_arg_conv.inner = untag_ptr(this_arg);
46847         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46849         this_arg_conv.is_owned = false;
46850         LDKLockableScore* ret_ret = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
46851         *ret_ret = MultiThreadedLockableScore_as_LockableScore(&this_arg_conv);
46852         return tag_ptr(ret_ret, true);
46853 }
46854
46855 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
46856         LDKMultiThreadedLockableScore obj_conv;
46857         obj_conv.inner = untag_ptr(obj);
46858         obj_conv.is_owned = ptr_is_owned(obj);
46859         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46860         obj_conv.is_owned = false;
46861         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
46862         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46863         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46864         CVec_u8Z_free(ret_var);
46865         return ret_arr;
46866 }
46867
46868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1as_1WriteableScore(JNIEnv *env, jclass clz, int64_t this_arg) {
46869         LDKMultiThreadedLockableScore this_arg_conv;
46870         this_arg_conv.inner = untag_ptr(this_arg);
46871         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46873         this_arg_conv.is_owned = false;
46874         LDKWriteableScore* ret_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
46875         *ret_ret = MultiThreadedLockableScore_as_WriteableScore(&this_arg_conv);
46876         return tag_ptr(ret_ret, true);
46877 }
46878
46879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
46880         void* score_ptr = untag_ptr(score);
46881         CHECK_ACCESS(score_ptr);
46882         LDKScore score_conv = *(LDKScore*)(score_ptr);
46883         if (score_conv.free == LDKScore_JCalls_free) {
46884                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46885                 LDKScore_JCalls_cloned(&score_conv);
46886         }
46887         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
46888         int64_t ret_ref = 0;
46889         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46890         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46891         return ret_ref;
46892 }
46893
46894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46895         LDKChannelUsage this_obj_conv;
46896         this_obj_conv.inner = untag_ptr(this_obj);
46897         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46899         ChannelUsage_free(this_obj_conv);
46900 }
46901
46902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46903         LDKChannelUsage this_ptr_conv;
46904         this_ptr_conv.inner = untag_ptr(this_ptr);
46905         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46907         this_ptr_conv.is_owned = false;
46908         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
46909         return ret_conv;
46910 }
46911
46912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46913         LDKChannelUsage this_ptr_conv;
46914         this_ptr_conv.inner = untag_ptr(this_ptr);
46915         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46917         this_ptr_conv.is_owned = false;
46918         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
46919 }
46920
46921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46922         LDKChannelUsage this_ptr_conv;
46923         this_ptr_conv.inner = untag_ptr(this_ptr);
46924         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46926         this_ptr_conv.is_owned = false;
46927         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
46928         return ret_conv;
46929 }
46930
46931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46932         LDKChannelUsage this_ptr_conv;
46933         this_ptr_conv.inner = untag_ptr(this_ptr);
46934         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46936         this_ptr_conv.is_owned = false;
46937         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
46938 }
46939
46940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr) {
46941         LDKChannelUsage this_ptr_conv;
46942         this_ptr_conv.inner = untag_ptr(this_ptr);
46943         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46945         this_ptr_conv.is_owned = false;
46946         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
46947         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
46948         int64_t ret_ref = tag_ptr(ret_copy, true);
46949         return ret_ref;
46950 }
46951
46952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46953         LDKChannelUsage this_ptr_conv;
46954         this_ptr_conv.inner = untag_ptr(this_ptr);
46955         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46957         this_ptr_conv.is_owned = false;
46958         void* val_ptr = untag_ptr(val);
46959         CHECK_ACCESS(val_ptr);
46960         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
46961         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(val));
46962         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
46963 }
46964
46965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1new(JNIEnv *env, jclass clz, int64_t amount_msat_arg, int64_t inflight_htlc_msat_arg, int64_t effective_capacity_arg) {
46966         void* effective_capacity_arg_ptr = untag_ptr(effective_capacity_arg);
46967         CHECK_ACCESS(effective_capacity_arg_ptr);
46968         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
46969         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(effective_capacity_arg));
46970         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
46971         int64_t ret_ref = 0;
46972         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46973         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46974         return ret_ref;
46975 }
46976
46977 static inline uint64_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
46978         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
46979         int64_t ret_ref = 0;
46980         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46981         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46982         return ret_ref;
46983 }
46984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46985         LDKChannelUsage arg_conv;
46986         arg_conv.inner = untag_ptr(arg);
46987         arg_conv.is_owned = ptr_is_owned(arg);
46988         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46989         arg_conv.is_owned = false;
46990         int64_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
46991         return ret_conv;
46992 }
46993
46994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46995         LDKChannelUsage orig_conv;
46996         orig_conv.inner = untag_ptr(orig);
46997         orig_conv.is_owned = ptr_is_owned(orig);
46998         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46999         orig_conv.is_owned = false;
47000         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
47001         int64_t ret_ref = 0;
47002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47003         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47004         return ret_ref;
47005 }
47006
47007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47008         LDKFixedPenaltyScorer this_obj_conv;
47009         this_obj_conv.inner = untag_ptr(this_obj);
47010         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47012         FixedPenaltyScorer_free(this_obj_conv);
47013 }
47014
47015 static inline uint64_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
47016         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
47017         int64_t ret_ref = 0;
47018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47019         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47020         return ret_ref;
47021 }
47022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47023         LDKFixedPenaltyScorer arg_conv;
47024         arg_conv.inner = untag_ptr(arg);
47025         arg_conv.is_owned = ptr_is_owned(arg);
47026         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47027         arg_conv.is_owned = false;
47028         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
47029         return ret_conv;
47030 }
47031
47032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47033         LDKFixedPenaltyScorer orig_conv;
47034         orig_conv.inner = untag_ptr(orig);
47035         orig_conv.is_owned = ptr_is_owned(orig);
47036         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47037         orig_conv.is_owned = false;
47038         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
47039         int64_t ret_ref = 0;
47040         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47041         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47042         return ret_ref;
47043 }
47044
47045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
47046         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
47047         int64_t ret_ref = 0;
47048         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47049         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47050         return ret_ref;
47051 }
47052
47053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
47054         LDKFixedPenaltyScorer this_arg_conv;
47055         this_arg_conv.inner = untag_ptr(this_arg);
47056         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47058         this_arg_conv.is_owned = false;
47059         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
47060         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
47061         return tag_ptr(ret_ret, true);
47062 }
47063
47064 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
47065         LDKFixedPenaltyScorer obj_conv;
47066         obj_conv.inner = untag_ptr(obj);
47067         obj_conv.is_owned = ptr_is_owned(obj);
47068         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47069         obj_conv.is_owned = false;
47070         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
47071         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47072         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47073         CVec_u8Z_free(ret_var);
47074         return ret_arr;
47075 }
47076
47077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
47078         LDKu8slice ser_ref;
47079         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47080         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47081         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
47082         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
47083         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47084         return tag_ptr(ret_conv, true);
47085 }
47086
47087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47088         LDKProbabilisticScorer this_obj_conv;
47089         this_obj_conv.inner = untag_ptr(this_obj);
47090         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47092         ProbabilisticScorer_free(this_obj_conv);
47093 }
47094
47095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47096         LDKProbabilisticScoringParameters this_obj_conv;
47097         this_obj_conv.inner = untag_ptr(this_obj);
47098         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47100         ProbabilisticScoringParameters_free(this_obj_conv);
47101 }
47102
47103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47104         LDKProbabilisticScoringParameters this_ptr_conv;
47105         this_ptr_conv.inner = untag_ptr(this_ptr);
47106         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47108         this_ptr_conv.is_owned = false;
47109         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
47110         return ret_conv;
47111 }
47112
47113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47114         LDKProbabilisticScoringParameters this_ptr_conv;
47115         this_ptr_conv.inner = untag_ptr(this_ptr);
47116         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47118         this_ptr_conv.is_owned = false;
47119         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
47120 }
47121
47122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47123         LDKProbabilisticScoringParameters this_ptr_conv;
47124         this_ptr_conv.inner = untag_ptr(this_ptr);
47125         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47127         this_ptr_conv.is_owned = false;
47128         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(&this_ptr_conv);
47129         return ret_conv;
47130 }
47131
47132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47133         LDKProbabilisticScoringParameters this_ptr_conv;
47134         this_ptr_conv.inner = untag_ptr(this_ptr);
47135         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47137         this_ptr_conv.is_owned = false;
47138         ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(&this_ptr_conv, val);
47139 }
47140
47141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47142         LDKProbabilisticScoringParameters this_ptr_conv;
47143         this_ptr_conv.inner = untag_ptr(this_ptr);
47144         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47146         this_ptr_conv.is_owned = false;
47147         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
47148         return ret_conv;
47149 }
47150
47151 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) {
47152         LDKProbabilisticScoringParameters this_ptr_conv;
47153         this_ptr_conv.inner = untag_ptr(this_ptr);
47154         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47156         this_ptr_conv.is_owned = false;
47157         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
47158 }
47159
47160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
47161         LDKProbabilisticScoringParameters this_ptr_conv;
47162         this_ptr_conv.inner = untag_ptr(this_ptr);
47163         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47165         this_ptr_conv.is_owned = false;
47166         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
47167         return ret_conv;
47168 }
47169
47170 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) {
47171         LDKProbabilisticScoringParameters this_ptr_conv;
47172         this_ptr_conv.inner = untag_ptr(this_ptr);
47173         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47175         this_ptr_conv.is_owned = false;
47176         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
47177 }
47178
47179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47180         LDKProbabilisticScoringParameters this_ptr_conv;
47181         this_ptr_conv.inner = untag_ptr(this_ptr);
47182         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47183         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47184         this_ptr_conv.is_owned = false;
47185         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
47186         return ret_conv;
47187 }
47188
47189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47190         LDKProbabilisticScoringParameters this_ptr_conv;
47191         this_ptr_conv.inner = untag_ptr(this_ptr);
47192         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47194         this_ptr_conv.is_owned = false;
47195         ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
47196 }
47197
47198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47199         LDKProbabilisticScoringParameters this_ptr_conv;
47200         this_ptr_conv.inner = untag_ptr(this_ptr);
47201         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47203         this_ptr_conv.is_owned = false;
47204         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
47205         return ret_conv;
47206 }
47207
47208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47209         LDKProbabilisticScoringParameters this_ptr_conv;
47210         this_ptr_conv.inner = untag_ptr(this_ptr);
47211         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47213         this_ptr_conv.is_owned = false;
47214         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
47215 }
47216
47217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1considered_1impossible_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
47218         LDKProbabilisticScoringParameters this_ptr_conv;
47219         this_ptr_conv.inner = untag_ptr(this_ptr);
47220         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47222         this_ptr_conv.is_owned = false;
47223         int64_t ret_conv = ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(&this_ptr_conv);
47224         return ret_conv;
47225 }
47226
47227 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1considered_1impossible_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47228         LDKProbabilisticScoringParameters this_ptr_conv;
47229         this_ptr_conv.inner = untag_ptr(this_ptr);
47230         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47231         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47232         this_ptr_conv.is_owned = false;
47233         ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(&this_ptr_conv, val);
47234 }
47235
47236 static inline uint64_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
47237         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
47238         int64_t ret_ref = 0;
47239         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47240         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47241         return ret_ref;
47242 }
47243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47244         LDKProbabilisticScoringParameters arg_conv;
47245         arg_conv.inner = untag_ptr(arg);
47246         arg_conv.is_owned = ptr_is_owned(arg);
47247         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47248         arg_conv.is_owned = false;
47249         int64_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
47250         return ret_conv;
47251 }
47252
47253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47254         LDKProbabilisticScoringParameters orig_conv;
47255         orig_conv.inner = untag_ptr(orig);
47256         orig_conv.is_owned = ptr_is_owned(orig);
47257         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47258         orig_conv.is_owned = false;
47259         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
47260         int64_t ret_ref = 0;
47261         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47262         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47263         return ret_ref;
47264 }
47265
47266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1new(JNIEnv *env, jclass clz, int64_t params, int64_t network_graph, int64_t logger) {
47267         LDKProbabilisticScoringParameters params_conv;
47268         params_conv.inner = untag_ptr(params);
47269         params_conv.is_owned = ptr_is_owned(params);
47270         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
47271         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
47272         LDKNetworkGraph network_graph_conv;
47273         network_graph_conv.inner = untag_ptr(network_graph);
47274         network_graph_conv.is_owned = ptr_is_owned(network_graph);
47275         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
47276         network_graph_conv.is_owned = false;
47277         void* logger_ptr = untag_ptr(logger);
47278         CHECK_ACCESS(logger_ptr);
47279         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
47280         if (logger_conv.free == LDKLogger_JCalls_free) {
47281                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47282                 LDKLogger_JCalls_cloned(&logger_conv);
47283         }
47284         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
47285         int64_t ret_ref = 0;
47286         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47287         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47288         return ret_ref;
47289 }
47290
47291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1debug_1log_1liquidity_1stats(JNIEnv *env, jclass clz, int64_t this_arg) {
47292         LDKProbabilisticScorer this_arg_conv;
47293         this_arg_conv.inner = untag_ptr(this_arg);
47294         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47296         this_arg_conv.is_owned = false;
47297         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
47298 }
47299
47300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1estimated_1channel_1liquidity_1range(JNIEnv *env, jclass clz, int64_t this_arg, int64_t scid, int64_t target) {
47301         LDKProbabilisticScorer this_arg_conv;
47302         this_arg_conv.inner = untag_ptr(this_arg);
47303         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47305         this_arg_conv.is_owned = false;
47306         LDKNodeId target_conv;
47307         target_conv.inner = untag_ptr(target);
47308         target_conv.is_owned = ptr_is_owned(target);
47309         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
47310         target_conv.is_owned = false;
47311         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
47312         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
47313         int64_t ret_ref = tag_ptr(ret_copy, true);
47314         return ret_ref;
47315 }
47316
47317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1add_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
47318         LDKProbabilisticScorer this_arg_conv;
47319         this_arg_conv.inner = untag_ptr(this_arg);
47320         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47322         this_arg_conv.is_owned = false;
47323         LDKNodeId node_id_conv;
47324         node_id_conv.inner = untag_ptr(node_id);
47325         node_id_conv.is_owned = ptr_is_owned(node_id);
47326         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
47327         node_id_conv.is_owned = false;
47328         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
47329 }
47330
47331 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
47332         LDKProbabilisticScorer this_arg_conv;
47333         this_arg_conv.inner = untag_ptr(this_arg);
47334         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47336         this_arg_conv.is_owned = false;
47337         LDKNodeId node_id_conv;
47338         node_id_conv.inner = untag_ptr(node_id);
47339         node_id_conv.is_owned = ptr_is_owned(node_id);
47340         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
47341         node_id_conv.is_owned = false;
47342         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
47343 }
47344
47345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1set_1manual_1penalty(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id, int64_t penalty) {
47346         LDKProbabilisticScorer this_arg_conv;
47347         this_arg_conv.inner = untag_ptr(this_arg);
47348         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47350         this_arg_conv.is_owned = false;
47351         LDKNodeId node_id_conv;
47352         node_id_conv.inner = untag_ptr(node_id);
47353         node_id_conv.is_owned = ptr_is_owned(node_id);
47354         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
47355         node_id_conv.is_owned = false;
47356         ProbabilisticScorer_set_manual_penalty(&this_arg_conv, &node_id_conv, penalty);
47357 }
47358
47359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1manual_1penalty(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
47360         LDKProbabilisticScorer this_arg_conv;
47361         this_arg_conv.inner = untag_ptr(this_arg);
47362         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47364         this_arg_conv.is_owned = false;
47365         LDKNodeId node_id_conv;
47366         node_id_conv.inner = untag_ptr(node_id);
47367         node_id_conv.is_owned = ptr_is_owned(node_id);
47368         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
47369         node_id_conv.is_owned = false;
47370         ProbabilisticScorer_remove_manual_penalty(&this_arg_conv, &node_id_conv);
47371 }
47372
47373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1clear_1manual_1penalties(JNIEnv *env, jclass clz, int64_t this_arg) {
47374         LDKProbabilisticScorer this_arg_conv;
47375         this_arg_conv.inner = untag_ptr(this_arg);
47376         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47378         this_arg_conv.is_owned = false;
47379         ProbabilisticScorer_clear_manual_penalties(&this_arg_conv);
47380 }
47381
47382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1add_1banned_1from_1list(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray node_ids) {
47383         LDKProbabilisticScoringParameters this_arg_conv;
47384         this_arg_conv.inner = untag_ptr(this_arg);
47385         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47387         this_arg_conv.is_owned = false;
47388         LDKCVec_NodeIdZ node_ids_constr;
47389         node_ids_constr.datalen = (*env)->GetArrayLength(env, node_ids);
47390         if (node_ids_constr.datalen > 0)
47391                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
47392         else
47393                 node_ids_constr.data = NULL;
47394         int64_t* node_ids_vals = (*env)->GetLongArrayElements (env, node_ids, NULL);
47395         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
47396                 int64_t node_ids_conv_8 = node_ids_vals[i];
47397                 LDKNodeId node_ids_conv_8_conv;
47398                 node_ids_conv_8_conv.inner = untag_ptr(node_ids_conv_8);
47399                 node_ids_conv_8_conv.is_owned = ptr_is_owned(node_ids_conv_8);
47400                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
47401                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
47402                 node_ids_constr.data[i] = node_ids_conv_8_conv;
47403         }
47404         (*env)->ReleaseLongArrayElements(env, node_ids, node_ids_vals, 0);
47405         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
47406 }
47407
47408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
47409         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
47410         int64_t ret_ref = 0;
47411         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47412         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47413         return ret_ref;
47414 }
47415
47416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
47417         LDKProbabilisticScorer this_arg_conv;
47418         this_arg_conv.inner = untag_ptr(this_arg);
47419         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47421         this_arg_conv.is_owned = false;
47422         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
47423         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
47424         return tag_ptr(ret_ret, true);
47425 }
47426
47427 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
47428         LDKProbabilisticScorer obj_conv;
47429         obj_conv.inner = untag_ptr(obj);
47430         obj_conv.is_owned = ptr_is_owned(obj);
47431         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47432         obj_conv.is_owned = false;
47433         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
47434         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47435         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47436         CVec_u8Z_free(ret_var);
47437         return ret_arr;
47438 }
47439
47440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg_a, int64_t arg_b, int64_t arg_c) {
47441         LDKu8slice ser_ref;
47442         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47443         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47444         LDKProbabilisticScoringParameters arg_a_conv;
47445         arg_a_conv.inner = untag_ptr(arg_a);
47446         arg_a_conv.is_owned = ptr_is_owned(arg_a);
47447         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
47448         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
47449         LDKNetworkGraph arg_b_conv;
47450         arg_b_conv.inner = untag_ptr(arg_b);
47451         arg_b_conv.is_owned = ptr_is_owned(arg_b);
47452         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
47453         arg_b_conv.is_owned = false;
47454         void* arg_c_ptr = untag_ptr(arg_c);
47455         CHECK_ACCESS(arg_c_ptr);
47456         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
47457         if (arg_c_conv.free == LDKLogger_JCalls_free) {
47458                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47459                 LDKLogger_JCalls_cloned(&arg_c_conv);
47460         }
47461         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
47462         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
47463         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47464         return tag_ptr(ret_conv, true);
47465 }
47466
47467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47468         LDKBlindedRoute this_obj_conv;
47469         this_obj_conv.inner = untag_ptr(this_obj);
47470         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47472         BlindedRoute_free(this_obj_conv);
47473 }
47474
47475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47476         LDKBlindedHop this_obj_conv;
47477         this_obj_conv.inner = untag_ptr(this_obj);
47478         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47480         BlindedHop_free(this_obj_conv);
47481 }
47482
47483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedRoute_1new(JNIEnv *env, jclass clz, jobjectArray node_pks, int64_t keys_manager) {
47484         LDKCVec_PublicKeyZ node_pks_constr;
47485         node_pks_constr.datalen = (*env)->GetArrayLength(env, node_pks);
47486         if (node_pks_constr.datalen > 0)
47487                 node_pks_constr.data = MALLOC(node_pks_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
47488         else
47489                 node_pks_constr.data = NULL;
47490         for (size_t i = 0; i < node_pks_constr.datalen; i++) {
47491                 int8_tArray node_pks_conv_8 = (*env)->GetObjectArrayElement(env, node_pks, i);
47492                 LDKPublicKey node_pks_conv_8_ref;
47493                 CHECK((*env)->GetArrayLength(env, node_pks_conv_8) == 33);
47494                 (*env)->GetByteArrayRegion(env, node_pks_conv_8, 0, 33, node_pks_conv_8_ref.compressed_form);
47495                 node_pks_constr.data[i] = node_pks_conv_8_ref;
47496         }
47497         void* keys_manager_ptr = untag_ptr(keys_manager);
47498         if (ptr_is_owned(keys_manager)) { CHECK_ACCESS(keys_manager_ptr); }
47499         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
47500         LDKCResult_BlindedRouteNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteNoneZ), "LDKCResult_BlindedRouteNoneZ");
47501         *ret_conv = BlindedRoute_new(node_pks_constr, keys_manager_conv);
47502         return tag_ptr(ret_conv, true);
47503 }
47504
47505 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedRoute_1write(JNIEnv *env, jclass clz, int64_t obj) {
47506         LDKBlindedRoute obj_conv;
47507         obj_conv.inner = untag_ptr(obj);
47508         obj_conv.is_owned = ptr_is_owned(obj);
47509         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47510         obj_conv.is_owned = false;
47511         LDKCVec_u8Z ret_var = BlindedRoute_write(&obj_conv);
47512         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47513         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47514         CVec_u8Z_free(ret_var);
47515         return ret_arr;
47516 }
47517
47518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedRoute_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47519         LDKu8slice ser_ref;
47520         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47521         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47522         LDKCResult_BlindedRouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedRouteDecodeErrorZ), "LDKCResult_BlindedRouteDecodeErrorZ");
47523         *ret_conv = BlindedRoute_read(ser_ref);
47524         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47525         return tag_ptr(ret_conv, true);
47526 }
47527
47528 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
47529         LDKBlindedHop obj_conv;
47530         obj_conv.inner = untag_ptr(obj);
47531         obj_conv.is_owned = ptr_is_owned(obj);
47532         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47533         obj_conv.is_owned = false;
47534         LDKCVec_u8Z ret_var = BlindedHop_write(&obj_conv);
47535         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47536         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47537         CVec_u8Z_free(ret_var);
47538         return ret_arr;
47539 }
47540
47541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47542         LDKu8slice ser_ref;
47543         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47544         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47545         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
47546         *ret_conv = BlindedHop_read(ser_ref);
47547         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47548         return tag_ptr(ret_conv, true);
47549 }
47550
47551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47552         LDKOnionMessenger this_obj_conv;
47553         this_obj_conv.inner = untag_ptr(this_obj);
47554         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47556         OnionMessenger_free(this_obj_conv);
47557 }
47558
47559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Destination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47560         if (!ptr_is_owned(this_ptr)) return;
47561         void* this_ptr_ptr = untag_ptr(this_ptr);
47562         CHECK_ACCESS(this_ptr_ptr);
47563         LDKDestination this_ptr_conv = *(LDKDestination*)(this_ptr_ptr);
47564         FREE(untag_ptr(this_ptr));
47565         Destination_free(this_ptr_conv);
47566 }
47567
47568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1node(JNIEnv *env, jclass clz, int8_tArray a) {
47569         LDKPublicKey a_ref;
47570         CHECK((*env)->GetArrayLength(env, a) == 33);
47571         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
47572         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
47573         *ret_copy = Destination_node(a_ref);
47574         int64_t ret_ref = tag_ptr(ret_copy, true);
47575         return ret_ref;
47576 }
47577
47578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1blinded_1route(JNIEnv *env, jclass clz, int64_t a) {
47579         LDKBlindedRoute a_conv;
47580         a_conv.inner = untag_ptr(a);
47581         a_conv.is_owned = ptr_is_owned(a);
47582         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47583         // WARNING: we need a move here but no clone is available for LDKBlindedRoute
47584         
47585         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
47586         *ret_copy = Destination_blinded_route(a_conv);
47587         int64_t ret_ref = tag_ptr(ret_copy, true);
47588         return ret_ref;
47589 }
47590
47591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SendError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47592         if (!ptr_is_owned(this_ptr)) return;
47593         void* this_ptr_ptr = untag_ptr(this_ptr);
47594         CHECK_ACCESS(this_ptr_ptr);
47595         LDKSendError this_ptr_conv = *(LDKSendError*)(this_ptr_ptr);
47596         FREE(untag_ptr(this_ptr));
47597         SendError_free(this_ptr_conv);
47598 }
47599
47600 static inline uint64_t SendError_clone_ptr(LDKSendError *NONNULL_PTR arg) {
47601         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
47602         *ret_copy = SendError_clone(arg);
47603         int64_t ret_ref = tag_ptr(ret_copy, true);
47604         return ret_ref;
47605 }
47606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47607         LDKSendError* arg_conv = (LDKSendError*)untag_ptr(arg);
47608         int64_t ret_conv = SendError_clone_ptr(arg_conv);
47609         return ret_conv;
47610 }
47611
47612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47613         LDKSendError* orig_conv = (LDKSendError*)untag_ptr(orig);
47614         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
47615         *ret_copy = SendError_clone(orig_conv);
47616         int64_t ret_ref = tag_ptr(ret_copy, true);
47617         return ret_ref;
47618 }
47619
47620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1secp256k1(JNIEnv *env, jclass clz, jclass a) {
47621         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
47622         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
47623         *ret_copy = SendError_secp256k1(a_conv);
47624         int64_t ret_ref = tag_ptr(ret_copy, true);
47625         return ret_ref;
47626 }
47627
47628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1too_1big_1packet(JNIEnv *env, jclass clz) {
47629         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
47630         *ret_copy = SendError_too_big_packet();
47631         int64_t ret_ref = tag_ptr(ret_copy, true);
47632         return ret_ref;
47633 }
47634
47635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1too_1few_1blinded_1hops(JNIEnv *env, jclass clz) {
47636         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
47637         *ret_copy = SendError_too_few_blinded_hops();
47638         int64_t ret_ref = tag_ptr(ret_copy, true);
47639         return ret_ref;
47640 }
47641
47642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1invalid_1first_1hop(JNIEnv *env, jclass clz) {
47643         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
47644         *ret_copy = SendError_invalid_first_hop();
47645         int64_t ret_ref = tag_ptr(ret_copy, true);
47646         return ret_ref;
47647 }
47648
47649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1buffer_1full(JNIEnv *env, jclass clz) {
47650         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
47651         *ret_copy = SendError_buffer_full();
47652         int64_t ret_ref = tag_ptr(ret_copy, true);
47653         return ret_ref;
47654 }
47655
47656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1new(JNIEnv *env, jclass clz, int64_t keys_manager, int64_t logger) {
47657         void* keys_manager_ptr = untag_ptr(keys_manager);
47658         CHECK_ACCESS(keys_manager_ptr);
47659         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
47660         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
47661                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47662                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
47663         }
47664         void* logger_ptr = untag_ptr(logger);
47665         CHECK_ACCESS(logger_ptr);
47666         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
47667         if (logger_conv.free == LDKLogger_JCalls_free) {
47668                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47669                 LDKLogger_JCalls_cloned(&logger_conv);
47670         }
47671         LDKOnionMessenger ret_var = OnionMessenger_new(keys_manager_conv, logger_conv);
47672         int64_t ret_ref = 0;
47673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47674         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47675         return ret_ref;
47676 }
47677
47678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1send_1onion_1message(JNIEnv *env, jclass clz, int64_t this_arg, jobjectArray intermediate_nodes, int64_t destination, int64_t reply_path) {
47679         LDKOnionMessenger this_arg_conv;
47680         this_arg_conv.inner = untag_ptr(this_arg);
47681         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47683         this_arg_conv.is_owned = false;
47684         LDKCVec_PublicKeyZ intermediate_nodes_constr;
47685         intermediate_nodes_constr.datalen = (*env)->GetArrayLength(env, intermediate_nodes);
47686         if (intermediate_nodes_constr.datalen > 0)
47687                 intermediate_nodes_constr.data = MALLOC(intermediate_nodes_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
47688         else
47689                 intermediate_nodes_constr.data = NULL;
47690         for (size_t i = 0; i < intermediate_nodes_constr.datalen; i++) {
47691                 int8_tArray intermediate_nodes_conv_8 = (*env)->GetObjectArrayElement(env, intermediate_nodes, i);
47692                 LDKPublicKey intermediate_nodes_conv_8_ref;
47693                 CHECK((*env)->GetArrayLength(env, intermediate_nodes_conv_8) == 33);
47694                 (*env)->GetByteArrayRegion(env, intermediate_nodes_conv_8, 0, 33, intermediate_nodes_conv_8_ref.compressed_form);
47695                 intermediate_nodes_constr.data[i] = intermediate_nodes_conv_8_ref;
47696         }
47697         void* destination_ptr = untag_ptr(destination);
47698         CHECK_ACCESS(destination_ptr);
47699         LDKDestination destination_conv = *(LDKDestination*)(destination_ptr);
47700         // WARNING: we may need a move here but no clone is available for LDKDestination
47701         LDKBlindedRoute reply_path_conv;
47702         reply_path_conv.inner = untag_ptr(reply_path);
47703         reply_path_conv.is_owned = ptr_is_owned(reply_path);
47704         CHECK_INNER_FIELD_ACCESS_OR_NULL(reply_path_conv);
47705         reply_path_conv.is_owned = false;
47706         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
47707         *ret_conv = OnionMessenger_send_onion_message(&this_arg_conv, intermediate_nodes_constr, destination_conv, reply_path_conv);
47708         return tag_ptr(ret_conv, true);
47709 }
47710
47711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1as_1OnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
47712         LDKOnionMessenger this_arg_conv;
47713         this_arg_conv.inner = untag_ptr(this_arg);
47714         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47716         this_arg_conv.is_owned = false;
47717         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
47718         *ret_ret = OnionMessenger_as_OnionMessageHandler(&this_arg_conv);
47719         return tag_ptr(ret_ret, true);
47720 }
47721
47722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1as_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
47723         LDKOnionMessenger this_arg_conv;
47724         this_arg_conv.inner = untag_ptr(this_arg);
47725         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47727         this_arg_conv.is_owned = false;
47728         LDKOnionMessageProvider* ret_ret = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
47729         *ret_ret = OnionMessenger_as_OnionMessageProvider(&this_arg_conv);
47730         return tag_ptr(ret_ret, true);
47731 }
47732
47733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47734         LDKFilesystemPersister this_obj_conv;
47735         this_obj_conv.inner = untag_ptr(this_obj);
47736         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47738         FilesystemPersister_free(this_obj_conv);
47739 }
47740
47741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
47742         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
47743         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
47744         int64_t ret_ref = 0;
47745         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47746         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47747         return ret_ref;
47748 }
47749
47750 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
47751         LDKFilesystemPersister this_arg_conv;
47752         this_arg_conv.inner = untag_ptr(this_arg);
47753         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47755         this_arg_conv.is_owned = false;
47756         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
47757         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
47758         Str_free(ret_str);
47759         return ret_conv;
47760 }
47761
47762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
47763         LDKFilesystemPersister this_arg_conv;
47764         this_arg_conv.inner = untag_ptr(this_arg);
47765         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47767         this_arg_conv.is_owned = false;
47768         void* keys_manager_ptr = untag_ptr(keys_manager);
47769         CHECK_ACCESS(keys_manager_ptr);
47770         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
47771         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
47772                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47773                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
47774         }
47775         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
47776         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
47777         return tag_ptr(ret_conv, true);
47778 }
47779
47780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47781         LDKBackgroundProcessor this_obj_conv;
47782         this_obj_conv.inner = untag_ptr(this_obj);
47783         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47785         BackgroundProcessor_free(this_obj_conv);
47786 }
47787
47788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipSync_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47789         if (!ptr_is_owned(this_ptr)) return;
47790         void* this_ptr_ptr = untag_ptr(this_ptr);
47791         CHECK_ACCESS(this_ptr_ptr);
47792         LDKGossipSync this_ptr_conv = *(LDKGossipSync*)(this_ptr_ptr);
47793         FREE(untag_ptr(this_ptr));
47794         GossipSync_free(this_ptr_conv);
47795 }
47796
47797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1p2_1p(JNIEnv *env, jclass clz, int64_t a) {
47798         LDKP2PGossipSync a_conv;
47799         a_conv.inner = untag_ptr(a);
47800         a_conv.is_owned = ptr_is_owned(a);
47801         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47802         a_conv.is_owned = false;
47803         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
47804         *ret_copy = GossipSync_p2_p(&a_conv);
47805         int64_t ret_ref = tag_ptr(ret_copy, true);
47806         return ret_ref;
47807 }
47808
47809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1rapid(JNIEnv *env, jclass clz, int64_t a) {
47810         LDKRapidGossipSync a_conv;
47811         a_conv.inner = untag_ptr(a);
47812         a_conv.is_owned = ptr_is_owned(a);
47813         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47814         a_conv.is_owned = false;
47815         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
47816         *ret_copy = GossipSync_rapid(&a_conv);
47817         int64_t ret_ref = tag_ptr(ret_copy, true);
47818         return ret_ref;
47819 }
47820
47821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1none(JNIEnv *env, jclass clz) {
47822         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
47823         *ret_copy = GossipSync_none();
47824         int64_t ret_ref = tag_ptr(ret_copy, true);
47825         return ret_ref;
47826 }
47827
47828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1start(JNIEnv *env, jclass clz, int64_t persister, int64_t event_handler, int64_t chain_monitor, int64_t channel_manager, int64_t gossip_sync, int64_t peer_manager, int64_t logger, int64_t scorer) {
47829         void* persister_ptr = untag_ptr(persister);
47830         CHECK_ACCESS(persister_ptr);
47831         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
47832         if (persister_conv.free == LDKPersister_JCalls_free) {
47833                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47834                 LDKPersister_JCalls_cloned(&persister_conv);
47835         }
47836         void* event_handler_ptr = untag_ptr(event_handler);
47837         CHECK_ACCESS(event_handler_ptr);
47838         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
47839         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
47840                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47841                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
47842         }
47843         LDKChainMonitor chain_monitor_conv;
47844         chain_monitor_conv.inner = untag_ptr(chain_monitor);
47845         chain_monitor_conv.is_owned = ptr_is_owned(chain_monitor);
47846         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
47847         chain_monitor_conv.is_owned = false;
47848         LDKChannelManager channel_manager_conv;
47849         channel_manager_conv.inner = untag_ptr(channel_manager);
47850         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
47851         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
47852         channel_manager_conv.is_owned = false;
47853         void* gossip_sync_ptr = untag_ptr(gossip_sync);
47854         CHECK_ACCESS(gossip_sync_ptr);
47855         LDKGossipSync gossip_sync_conv = *(LDKGossipSync*)(gossip_sync_ptr);
47856         // WARNING: we may need a move here but no clone is available for LDKGossipSync
47857         LDKPeerManager peer_manager_conv;
47858         peer_manager_conv.inner = untag_ptr(peer_manager);
47859         peer_manager_conv.is_owned = ptr_is_owned(peer_manager);
47860         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
47861         peer_manager_conv.is_owned = false;
47862         void* logger_ptr = untag_ptr(logger);
47863         CHECK_ACCESS(logger_ptr);
47864         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
47865         if (logger_conv.free == LDKLogger_JCalls_free) {
47866                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47867                 LDKLogger_JCalls_cloned(&logger_conv);
47868         }
47869         void* scorer_ptr = untag_ptr(scorer);
47870         CHECK_ACCESS(scorer_ptr);
47871         LDKCOption_WriteableScoreZ scorer_conv = *(LDKCOption_WriteableScoreZ*)(scorer_ptr);
47872         // WARNING: we may need a move here but no clone is available for LDKCOption_WriteableScoreZ
47873         if (scorer_conv.tag == LDKCOption_WriteableScoreZ_Some) {
47874                 // Manually implement clone for Java trait instances
47875                 if (scorer_conv.some.free == LDKWriteableScore_JCalls_free) {
47876                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47877                         LDKWriteableScore_JCalls_cloned(&scorer_conv.some);
47878                 }
47879         }
47880         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, gossip_sync_conv, &peer_manager_conv, logger_conv, scorer_conv);
47881         int64_t ret_ref = 0;
47882         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47883         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47884         return ret_ref;
47885 }
47886
47887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
47888         LDKBackgroundProcessor this_arg_conv;
47889         this_arg_conv.inner = untag_ptr(this_arg);
47890         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47892         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
47893         
47894         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
47895         *ret_conv = BackgroundProcessor_join(this_arg_conv);
47896         return tag_ptr(ret_conv, true);
47897 }
47898
47899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
47900         LDKBackgroundProcessor this_arg_conv;
47901         this_arg_conv.inner = untag_ptr(this_arg);
47902         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47904         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
47905         
47906         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
47907         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
47908         return tag_ptr(ret_conv, true);
47909 }
47910
47911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47912         if (!ptr_is_owned(this_ptr)) return;
47913         void* this_ptr_ptr = untag_ptr(this_ptr);
47914         CHECK_ACCESS(this_ptr_ptr);
47915         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
47916         FREE(untag_ptr(this_ptr));
47917         ParseError_free(this_ptr_conv);
47918 }
47919
47920 static inline uint64_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
47921         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47922         *ret_copy = ParseError_clone(arg);
47923         int64_t ret_ref = tag_ptr(ret_copy, true);
47924         return ret_ref;
47925 }
47926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47927         LDKParseError* arg_conv = (LDKParseError*)untag_ptr(arg);
47928         int64_t ret_conv = ParseError_clone_ptr(arg_conv);
47929         return ret_conv;
47930 }
47931
47932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47933         LDKParseError* orig_conv = (LDKParseError*)untag_ptr(orig);
47934         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47935         *ret_copy = ParseError_clone(orig_conv);
47936         int64_t ret_ref = tag_ptr(ret_copy, true);
47937         return ret_ref;
47938 }
47939
47940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bech32_1error(JNIEnv *env, jclass clz, int64_t a) {
47941         void* a_ptr = untag_ptr(a);
47942         CHECK_ACCESS(a_ptr);
47943         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
47944         a_conv = Bech32Error_clone((LDKBech32Error*)untag_ptr(a));
47945         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47946         *ret_copy = ParseError_bech32_error(a_conv);
47947         int64_t ret_ref = tag_ptr(ret_copy, true);
47948         return ret_ref;
47949 }
47950
47951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1parse_1amount_1error(JNIEnv *env, jclass clz, int32_t a) {
47952         
47953         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47954         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
47955         int64_t ret_ref = tag_ptr(ret_copy, true);
47956         return ret_ref;
47957 }
47958
47959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1signature(JNIEnv *env, jclass clz, jclass a) {
47960         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
47961         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47962         *ret_copy = ParseError_malformed_signature(a_conv);
47963         int64_t ret_ref = tag_ptr(ret_copy, true);
47964         return ret_ref;
47965 }
47966
47967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bad_1prefix(JNIEnv *env, jclass clz) {
47968         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47969         *ret_copy = ParseError_bad_prefix();
47970         int64_t ret_ref = tag_ptr(ret_copy, true);
47971         return ret_ref;
47972 }
47973
47974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1currency(JNIEnv *env, jclass clz) {
47975         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47976         *ret_copy = ParseError_unknown_currency();
47977         int64_t ret_ref = tag_ptr(ret_copy, true);
47978         return ret_ref;
47979 }
47980
47981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1si_1prefix(JNIEnv *env, jclass clz) {
47982         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47983         *ret_copy = ParseError_unknown_si_prefix();
47984         int64_t ret_ref = tag_ptr(ret_copy, true);
47985         return ret_ref;
47986 }
47987
47988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1hrp(JNIEnv *env, jclass clz) {
47989         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47990         *ret_copy = ParseError_malformed_hrp();
47991         int64_t ret_ref = tag_ptr(ret_copy, true);
47992         return ret_ref;
47993 }
47994
47995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1too_1short_1data_1part(JNIEnv *env, jclass clz) {
47996         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
47997         *ret_copy = ParseError_too_short_data_part();
47998         int64_t ret_ref = tag_ptr(ret_copy, true);
47999         return ret_ref;
48000 }
48001
48002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unexpected_1end_1of_1tagged_1fields(JNIEnv *env, jclass clz) {
48003         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
48004         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
48005         int64_t ret_ref = tag_ptr(ret_copy, true);
48006         return ret_ref;
48007 }
48008
48009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1description_1decode_1error(JNIEnv *env, jclass clz, int32_t a) {
48010         
48011         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
48012         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
48013         int64_t ret_ref = tag_ptr(ret_copy, true);
48014         return ret_ref;
48015 }
48016
48017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1padding_1error(JNIEnv *env, jclass clz) {
48018         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
48019         *ret_copy = ParseError_padding_error();
48020         int64_t ret_ref = tag_ptr(ret_copy, true);
48021         return ret_ref;
48022 }
48023
48024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1integer_1overflow_1error(JNIEnv *env, jclass clz) {
48025         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
48026         *ret_copy = ParseError_integer_overflow_error();
48027         int64_t ret_ref = tag_ptr(ret_copy, true);
48028         return ret_ref;
48029 }
48030
48031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1seg_1wit_1program_1length(JNIEnv *env, jclass clz) {
48032         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
48033         *ret_copy = ParseError_invalid_seg_wit_program_length();
48034         int64_t ret_ref = tag_ptr(ret_copy, true);
48035         return ret_ref;
48036 }
48037
48038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1pub_1key_1hash_1length(JNIEnv *env, jclass clz) {
48039         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
48040         *ret_copy = ParseError_invalid_pub_key_hash_length();
48041         int64_t ret_ref = tag_ptr(ret_copy, true);
48042         return ret_ref;
48043 }
48044
48045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1script_1hash_1length(JNIEnv *env, jclass clz) {
48046         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
48047         *ret_copy = ParseError_invalid_script_hash_length();
48048         int64_t ret_ref = tag_ptr(ret_copy, true);
48049         return ret_ref;
48050 }
48051
48052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
48053         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
48054         *ret_copy = ParseError_invalid_recovery_id();
48055         int64_t ret_ref = tag_ptr(ret_copy, true);
48056         return ret_ref;
48057 }
48058
48059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1slice_1length(JNIEnv *env, jclass clz, jstring a) {
48060         LDKStr a_conv = java_to_owned_str(env, a);
48061         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
48062         *ret_copy = ParseError_invalid_slice_length(a_conv);
48063         int64_t ret_ref = tag_ptr(ret_copy, true);
48064         return ret_ref;
48065 }
48066
48067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1skip(JNIEnv *env, jclass clz) {
48068         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
48069         *ret_copy = ParseError_skip();
48070         int64_t ret_ref = tag_ptr(ret_copy, true);
48071         return ret_ref;
48072 }
48073
48074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48075         if (!ptr_is_owned(this_ptr)) return;
48076         void* this_ptr_ptr = untag_ptr(this_ptr);
48077         CHECK_ACCESS(this_ptr_ptr);
48078         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
48079         FREE(untag_ptr(this_ptr));
48080         ParseOrSemanticError_free(this_ptr_conv);
48081 }
48082
48083 static inline uint64_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
48084         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
48085         *ret_copy = ParseOrSemanticError_clone(arg);
48086         int64_t ret_ref = tag_ptr(ret_copy, true);
48087         return ret_ref;
48088 }
48089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48090         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)untag_ptr(arg);
48091         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
48092         return ret_conv;
48093 }
48094
48095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48096         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)untag_ptr(orig);
48097         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
48098         *ret_copy = ParseOrSemanticError_clone(orig_conv);
48099         int64_t ret_ref = tag_ptr(ret_copy, true);
48100         return ret_ref;
48101 }
48102
48103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1parse_1error(JNIEnv *env, jclass clz, int64_t a) {
48104         void* a_ptr = untag_ptr(a);
48105         CHECK_ACCESS(a_ptr);
48106         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
48107         a_conv = ParseError_clone((LDKParseError*)untag_ptr(a));
48108         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
48109         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
48110         int64_t ret_ref = tag_ptr(ret_copy, true);
48111         return ret_ref;
48112 }
48113
48114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1semantic_1error(JNIEnv *env, jclass clz, jclass a) {
48115         LDKSemanticError a_conv = LDKSemanticError_from_java(env, a);
48116         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
48117         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
48118         int64_t ret_ref = tag_ptr(ret_copy, true);
48119         return ret_ref;
48120 }
48121
48122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48123         LDKInvoice this_obj_conv;
48124         this_obj_conv.inner = untag_ptr(this_obj);
48125         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48127         Invoice_free(this_obj_conv);
48128 }
48129
48130 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48131         LDKInvoice a_conv;
48132         a_conv.inner = untag_ptr(a);
48133         a_conv.is_owned = ptr_is_owned(a);
48134         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48135         a_conv.is_owned = false;
48136         LDKInvoice b_conv;
48137         b_conv.inner = untag_ptr(b);
48138         b_conv.is_owned = ptr_is_owned(b);
48139         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48140         b_conv.is_owned = false;
48141         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
48142         return ret_conv;
48143 }
48144
48145 static inline uint64_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
48146         LDKInvoice ret_var = Invoice_clone(arg);
48147         int64_t ret_ref = 0;
48148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48149         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48150         return ret_ref;
48151 }
48152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48153         LDKInvoice arg_conv;
48154         arg_conv.inner = untag_ptr(arg);
48155         arg_conv.is_owned = ptr_is_owned(arg);
48156         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48157         arg_conv.is_owned = false;
48158         int64_t ret_conv = Invoice_clone_ptr(&arg_conv);
48159         return ret_conv;
48160 }
48161
48162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48163         LDKInvoice orig_conv;
48164         orig_conv.inner = untag_ptr(orig);
48165         orig_conv.is_owned = ptr_is_owned(orig);
48166         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48167         orig_conv.is_owned = false;
48168         LDKInvoice ret_var = Invoice_clone(&orig_conv);
48169         int64_t ret_ref = 0;
48170         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48171         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48172         return ret_ref;
48173 }
48174
48175 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
48176         LDKInvoice o_conv;
48177         o_conv.inner = untag_ptr(o);
48178         o_conv.is_owned = ptr_is_owned(o);
48179         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48180         o_conv.is_owned = false;
48181         int64_t ret_conv = Invoice_hash(&o_conv);
48182         return ret_conv;
48183 }
48184
48185 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48186         LDKSignedRawInvoice this_obj_conv;
48187         this_obj_conv.inner = untag_ptr(this_obj);
48188         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48190         SignedRawInvoice_free(this_obj_conv);
48191 }
48192
48193 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48194         LDKSignedRawInvoice a_conv;
48195         a_conv.inner = untag_ptr(a);
48196         a_conv.is_owned = ptr_is_owned(a);
48197         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48198         a_conv.is_owned = false;
48199         LDKSignedRawInvoice b_conv;
48200         b_conv.inner = untag_ptr(b);
48201         b_conv.is_owned = ptr_is_owned(b);
48202         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48203         b_conv.is_owned = false;
48204         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
48205         return ret_conv;
48206 }
48207
48208 static inline uint64_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
48209         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
48210         int64_t ret_ref = 0;
48211         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48212         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48213         return ret_ref;
48214 }
48215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48216         LDKSignedRawInvoice arg_conv;
48217         arg_conv.inner = untag_ptr(arg);
48218         arg_conv.is_owned = ptr_is_owned(arg);
48219         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48220         arg_conv.is_owned = false;
48221         int64_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
48222         return ret_conv;
48223 }
48224
48225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48226         LDKSignedRawInvoice orig_conv;
48227         orig_conv.inner = untag_ptr(orig);
48228         orig_conv.is_owned = ptr_is_owned(orig);
48229         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48230         orig_conv.is_owned = false;
48231         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
48232         int64_t ret_ref = 0;
48233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48234         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48235         return ret_ref;
48236 }
48237
48238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
48239         LDKSignedRawInvoice o_conv;
48240         o_conv.inner = untag_ptr(o);
48241         o_conv.is_owned = ptr_is_owned(o);
48242         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48243         o_conv.is_owned = false;
48244         int64_t ret_conv = SignedRawInvoice_hash(&o_conv);
48245         return ret_conv;
48246 }
48247
48248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48249         LDKRawInvoice this_obj_conv;
48250         this_obj_conv.inner = untag_ptr(this_obj);
48251         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48253         RawInvoice_free(this_obj_conv);
48254 }
48255
48256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
48257         LDKRawInvoice this_ptr_conv;
48258         this_ptr_conv.inner = untag_ptr(this_ptr);
48259         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48261         this_ptr_conv.is_owned = false;
48262         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
48263         int64_t ret_ref = 0;
48264         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48265         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48266         return ret_ref;
48267 }
48268
48269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48270         LDKRawInvoice this_ptr_conv;
48271         this_ptr_conv.inner = untag_ptr(this_ptr);
48272         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48274         this_ptr_conv.is_owned = false;
48275         LDKRawDataPart val_conv;
48276         val_conv.inner = untag_ptr(val);
48277         val_conv.is_owned = ptr_is_owned(val);
48278         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48279         val_conv = RawDataPart_clone(&val_conv);
48280         RawInvoice_set_data(&this_ptr_conv, val_conv);
48281 }
48282
48283 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48284         LDKRawInvoice a_conv;
48285         a_conv.inner = untag_ptr(a);
48286         a_conv.is_owned = ptr_is_owned(a);
48287         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48288         a_conv.is_owned = false;
48289         LDKRawInvoice b_conv;
48290         b_conv.inner = untag_ptr(b);
48291         b_conv.is_owned = ptr_is_owned(b);
48292         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48293         b_conv.is_owned = false;
48294         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
48295         return ret_conv;
48296 }
48297
48298 static inline uint64_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
48299         LDKRawInvoice ret_var = RawInvoice_clone(arg);
48300         int64_t ret_ref = 0;
48301         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48302         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48303         return ret_ref;
48304 }
48305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48306         LDKRawInvoice arg_conv;
48307         arg_conv.inner = untag_ptr(arg);
48308         arg_conv.is_owned = ptr_is_owned(arg);
48309         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48310         arg_conv.is_owned = false;
48311         int64_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
48312         return ret_conv;
48313 }
48314
48315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48316         LDKRawInvoice orig_conv;
48317         orig_conv.inner = untag_ptr(orig);
48318         orig_conv.is_owned = ptr_is_owned(orig);
48319         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48320         orig_conv.is_owned = false;
48321         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
48322         int64_t ret_ref = 0;
48323         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48324         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48325         return ret_ref;
48326 }
48327
48328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
48329         LDKRawInvoice o_conv;
48330         o_conv.inner = untag_ptr(o);
48331         o_conv.is_owned = ptr_is_owned(o);
48332         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48333         o_conv.is_owned = false;
48334         int64_t ret_conv = RawInvoice_hash(&o_conv);
48335         return ret_conv;
48336 }
48337
48338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48339         LDKRawDataPart this_obj_conv;
48340         this_obj_conv.inner = untag_ptr(this_obj);
48341         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48343         RawDataPart_free(this_obj_conv);
48344 }
48345
48346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
48347         LDKRawDataPart this_ptr_conv;
48348         this_ptr_conv.inner = untag_ptr(this_ptr);
48349         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48351         this_ptr_conv.is_owned = false;
48352         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
48353         int64_t ret_ref = 0;
48354         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48355         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48356         return ret_ref;
48357 }
48358
48359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48360         LDKRawDataPart this_ptr_conv;
48361         this_ptr_conv.inner = untag_ptr(this_ptr);
48362         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48364         this_ptr_conv.is_owned = false;
48365         LDKPositiveTimestamp val_conv;
48366         val_conv.inner = untag_ptr(val);
48367         val_conv.is_owned = ptr_is_owned(val);
48368         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48369         val_conv = PositiveTimestamp_clone(&val_conv);
48370         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
48371 }
48372
48373 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48374         LDKRawDataPart a_conv;
48375         a_conv.inner = untag_ptr(a);
48376         a_conv.is_owned = ptr_is_owned(a);
48377         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48378         a_conv.is_owned = false;
48379         LDKRawDataPart b_conv;
48380         b_conv.inner = untag_ptr(b);
48381         b_conv.is_owned = ptr_is_owned(b);
48382         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48383         b_conv.is_owned = false;
48384         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
48385         return ret_conv;
48386 }
48387
48388 static inline uint64_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
48389         LDKRawDataPart ret_var = RawDataPart_clone(arg);
48390         int64_t ret_ref = 0;
48391         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48392         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48393         return ret_ref;
48394 }
48395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48396         LDKRawDataPart arg_conv;
48397         arg_conv.inner = untag_ptr(arg);
48398         arg_conv.is_owned = ptr_is_owned(arg);
48399         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48400         arg_conv.is_owned = false;
48401         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
48402         return ret_conv;
48403 }
48404
48405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48406         LDKRawDataPart orig_conv;
48407         orig_conv.inner = untag_ptr(orig);
48408         orig_conv.is_owned = ptr_is_owned(orig);
48409         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48410         orig_conv.is_owned = false;
48411         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
48412         int64_t ret_ref = 0;
48413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48414         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48415         return ret_ref;
48416 }
48417
48418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1hash(JNIEnv *env, jclass clz, int64_t o) {
48419         LDKRawDataPart o_conv;
48420         o_conv.inner = untag_ptr(o);
48421         o_conv.is_owned = ptr_is_owned(o);
48422         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48423         o_conv.is_owned = false;
48424         int64_t ret_conv = RawDataPart_hash(&o_conv);
48425         return ret_conv;
48426 }
48427
48428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48429         LDKPositiveTimestamp this_obj_conv;
48430         this_obj_conv.inner = untag_ptr(this_obj);
48431         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48433         PositiveTimestamp_free(this_obj_conv);
48434 }
48435
48436 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48437         LDKPositiveTimestamp a_conv;
48438         a_conv.inner = untag_ptr(a);
48439         a_conv.is_owned = ptr_is_owned(a);
48440         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48441         a_conv.is_owned = false;
48442         LDKPositiveTimestamp b_conv;
48443         b_conv.inner = untag_ptr(b);
48444         b_conv.is_owned = ptr_is_owned(b);
48445         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48446         b_conv.is_owned = false;
48447         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
48448         return ret_conv;
48449 }
48450
48451 static inline uint64_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
48452         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
48453         int64_t ret_ref = 0;
48454         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48455         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48456         return ret_ref;
48457 }
48458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48459         LDKPositiveTimestamp arg_conv;
48460         arg_conv.inner = untag_ptr(arg);
48461         arg_conv.is_owned = ptr_is_owned(arg);
48462         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48463         arg_conv.is_owned = false;
48464         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
48465         return ret_conv;
48466 }
48467
48468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48469         LDKPositiveTimestamp orig_conv;
48470         orig_conv.inner = untag_ptr(orig);
48471         orig_conv.is_owned = ptr_is_owned(orig);
48472         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48473         orig_conv.is_owned = false;
48474         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
48475         int64_t ret_ref = 0;
48476         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48477         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48478         return ret_ref;
48479 }
48480
48481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1hash(JNIEnv *env, jclass clz, int64_t o) {
48482         LDKPositiveTimestamp o_conv;
48483         o_conv.inner = untag_ptr(o);
48484         o_conv.is_owned = ptr_is_owned(o);
48485         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48486         o_conv.is_owned = false;
48487         int64_t ret_conv = PositiveTimestamp_hash(&o_conv);
48488         return ret_conv;
48489 }
48490
48491 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48492         LDKSiPrefix* orig_conv = (LDKSiPrefix*)untag_ptr(orig);
48493         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
48494         return ret_conv;
48495 }
48496
48497 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
48498         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
48499         return ret_conv;
48500 }
48501
48502 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
48503         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
48504         return ret_conv;
48505 }
48506
48507 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
48508         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
48509         return ret_conv;
48510 }
48511
48512 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
48513         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
48514         return ret_conv;
48515 }
48516
48517 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48518         LDKSiPrefix* a_conv = (LDKSiPrefix*)untag_ptr(a);
48519         LDKSiPrefix* b_conv = (LDKSiPrefix*)untag_ptr(b);
48520         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
48521         return ret_conv;
48522 }
48523
48524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1hash(JNIEnv *env, jclass clz, int64_t o) {
48525         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
48526         int64_t ret_conv = SiPrefix_hash(o_conv);
48527         return ret_conv;
48528 }
48529
48530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
48531         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)untag_ptr(this_arg);
48532         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
48533         return ret_conv;
48534 }
48535
48536 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48537         LDKCurrency* orig_conv = (LDKCurrency*)untag_ptr(orig);
48538         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
48539         return ret_conv;
48540 }
48541
48542 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
48543         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
48544         return ret_conv;
48545 }
48546
48547 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
48548         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
48549         return ret_conv;
48550 }
48551
48552 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
48553         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
48554         return ret_conv;
48555 }
48556
48557 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
48558         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
48559         return ret_conv;
48560 }
48561
48562 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
48563         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
48564         return ret_conv;
48565 }
48566
48567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
48568         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
48569         int64_t ret_conv = Currency_hash(o_conv);
48570         return ret_conv;
48571 }
48572
48573 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48574         LDKCurrency* a_conv = (LDKCurrency*)untag_ptr(a);
48575         LDKCurrency* b_conv = (LDKCurrency*)untag_ptr(b);
48576         jboolean ret_conv = Currency_eq(a_conv, b_conv);
48577         return ret_conv;
48578 }
48579
48580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48581         LDKSha256 this_obj_conv;
48582         this_obj_conv.inner = untag_ptr(this_obj);
48583         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48585         Sha256_free(this_obj_conv);
48586 }
48587
48588 static inline uint64_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
48589         LDKSha256 ret_var = Sha256_clone(arg);
48590         int64_t ret_ref = 0;
48591         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48592         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48593         return ret_ref;
48594 }
48595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48596         LDKSha256 arg_conv;
48597         arg_conv.inner = untag_ptr(arg);
48598         arg_conv.is_owned = ptr_is_owned(arg);
48599         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48600         arg_conv.is_owned = false;
48601         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
48602         return ret_conv;
48603 }
48604
48605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48606         LDKSha256 orig_conv;
48607         orig_conv.inner = untag_ptr(orig);
48608         orig_conv.is_owned = ptr_is_owned(orig);
48609         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48610         orig_conv.is_owned = false;
48611         LDKSha256 ret_var = Sha256_clone(&orig_conv);
48612         int64_t ret_ref = 0;
48613         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48614         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48615         return ret_ref;
48616 }
48617
48618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
48619         LDKSha256 o_conv;
48620         o_conv.inner = untag_ptr(o);
48621         o_conv.is_owned = ptr_is_owned(o);
48622         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48623         o_conv.is_owned = false;
48624         int64_t ret_conv = Sha256_hash(&o_conv);
48625         return ret_conv;
48626 }
48627
48628 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48629         LDKSha256 a_conv;
48630         a_conv.inner = untag_ptr(a);
48631         a_conv.is_owned = ptr_is_owned(a);
48632         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48633         a_conv.is_owned = false;
48634         LDKSha256 b_conv;
48635         b_conv.inner = untag_ptr(b);
48636         b_conv.is_owned = ptr_is_owned(b);
48637         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48638         b_conv.is_owned = false;
48639         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
48640         return ret_conv;
48641 }
48642
48643 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48644         LDKDescription this_obj_conv;
48645         this_obj_conv.inner = untag_ptr(this_obj);
48646         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48647         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48648         Description_free(this_obj_conv);
48649 }
48650
48651 static inline uint64_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
48652         LDKDescription ret_var = Description_clone(arg);
48653         int64_t ret_ref = 0;
48654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48655         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48656         return ret_ref;
48657 }
48658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48659         LDKDescription arg_conv;
48660         arg_conv.inner = untag_ptr(arg);
48661         arg_conv.is_owned = ptr_is_owned(arg);
48662         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48663         arg_conv.is_owned = false;
48664         int64_t ret_conv = Description_clone_ptr(&arg_conv);
48665         return ret_conv;
48666 }
48667
48668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48669         LDKDescription orig_conv;
48670         orig_conv.inner = untag_ptr(orig);
48671         orig_conv.is_owned = ptr_is_owned(orig);
48672         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48673         orig_conv.is_owned = false;
48674         LDKDescription ret_var = Description_clone(&orig_conv);
48675         int64_t ret_ref = 0;
48676         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48677         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48678         return ret_ref;
48679 }
48680
48681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
48682         LDKDescription o_conv;
48683         o_conv.inner = untag_ptr(o);
48684         o_conv.is_owned = ptr_is_owned(o);
48685         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48686         o_conv.is_owned = false;
48687         int64_t ret_conv = Description_hash(&o_conv);
48688         return ret_conv;
48689 }
48690
48691 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48692         LDKDescription a_conv;
48693         a_conv.inner = untag_ptr(a);
48694         a_conv.is_owned = ptr_is_owned(a);
48695         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48696         a_conv.is_owned = false;
48697         LDKDescription b_conv;
48698         b_conv.inner = untag_ptr(b);
48699         b_conv.is_owned = ptr_is_owned(b);
48700         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48701         b_conv.is_owned = false;
48702         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
48703         return ret_conv;
48704 }
48705
48706 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48707         LDKPayeePubKey this_obj_conv;
48708         this_obj_conv.inner = untag_ptr(this_obj);
48709         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48711         PayeePubKey_free(this_obj_conv);
48712 }
48713
48714 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
48715         LDKPayeePubKey this_ptr_conv;
48716         this_ptr_conv.inner = untag_ptr(this_ptr);
48717         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48719         this_ptr_conv.is_owned = false;
48720         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
48721         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
48722         return ret_arr;
48723 }
48724
48725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
48726         LDKPayeePubKey this_ptr_conv;
48727         this_ptr_conv.inner = untag_ptr(this_ptr);
48728         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48730         this_ptr_conv.is_owned = false;
48731         LDKPublicKey val_ref;
48732         CHECK((*env)->GetArrayLength(env, val) == 33);
48733         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
48734         PayeePubKey_set_a(&this_ptr_conv, val_ref);
48735 }
48736
48737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
48738         LDKPublicKey a_arg_ref;
48739         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
48740         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
48741         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
48742         int64_t ret_ref = 0;
48743         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48744         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48745         return ret_ref;
48746 }
48747
48748 static inline uint64_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
48749         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
48750         int64_t ret_ref = 0;
48751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48752         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48753         return ret_ref;
48754 }
48755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48756         LDKPayeePubKey arg_conv;
48757         arg_conv.inner = untag_ptr(arg);
48758         arg_conv.is_owned = ptr_is_owned(arg);
48759         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48760         arg_conv.is_owned = false;
48761         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
48762         return ret_conv;
48763 }
48764
48765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48766         LDKPayeePubKey orig_conv;
48767         orig_conv.inner = untag_ptr(orig);
48768         orig_conv.is_owned = ptr_is_owned(orig);
48769         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48770         orig_conv.is_owned = false;
48771         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
48772         int64_t ret_ref = 0;
48773         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48774         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48775         return ret_ref;
48776 }
48777
48778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
48779         LDKPayeePubKey o_conv;
48780         o_conv.inner = untag_ptr(o);
48781         o_conv.is_owned = ptr_is_owned(o);
48782         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48783         o_conv.is_owned = false;
48784         int64_t ret_conv = PayeePubKey_hash(&o_conv);
48785         return ret_conv;
48786 }
48787
48788 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48789         LDKPayeePubKey a_conv;
48790         a_conv.inner = untag_ptr(a);
48791         a_conv.is_owned = ptr_is_owned(a);
48792         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48793         a_conv.is_owned = false;
48794         LDKPayeePubKey b_conv;
48795         b_conv.inner = untag_ptr(b);
48796         b_conv.is_owned = ptr_is_owned(b);
48797         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48798         b_conv.is_owned = false;
48799         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
48800         return ret_conv;
48801 }
48802
48803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48804         LDKExpiryTime this_obj_conv;
48805         this_obj_conv.inner = untag_ptr(this_obj);
48806         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48808         ExpiryTime_free(this_obj_conv);
48809 }
48810
48811 static inline uint64_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
48812         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
48813         int64_t ret_ref = 0;
48814         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48815         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48816         return ret_ref;
48817 }
48818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48819         LDKExpiryTime arg_conv;
48820         arg_conv.inner = untag_ptr(arg);
48821         arg_conv.is_owned = ptr_is_owned(arg);
48822         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48823         arg_conv.is_owned = false;
48824         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
48825         return ret_conv;
48826 }
48827
48828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48829         LDKExpiryTime orig_conv;
48830         orig_conv.inner = untag_ptr(orig);
48831         orig_conv.is_owned = ptr_is_owned(orig);
48832         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48833         orig_conv.is_owned = false;
48834         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
48835         int64_t ret_ref = 0;
48836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48837         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48838         return ret_ref;
48839 }
48840
48841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
48842         LDKExpiryTime o_conv;
48843         o_conv.inner = untag_ptr(o);
48844         o_conv.is_owned = ptr_is_owned(o);
48845         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48846         o_conv.is_owned = false;
48847         int64_t ret_conv = ExpiryTime_hash(&o_conv);
48848         return ret_conv;
48849 }
48850
48851 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48852         LDKExpiryTime a_conv;
48853         a_conv.inner = untag_ptr(a);
48854         a_conv.is_owned = ptr_is_owned(a);
48855         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48856         a_conv.is_owned = false;
48857         LDKExpiryTime b_conv;
48858         b_conv.inner = untag_ptr(b);
48859         b_conv.is_owned = ptr_is_owned(b);
48860         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48861         b_conv.is_owned = false;
48862         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
48863         return ret_conv;
48864 }
48865
48866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48867         LDKMinFinalCltvExpiry this_obj_conv;
48868         this_obj_conv.inner = untag_ptr(this_obj);
48869         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48871         MinFinalCltvExpiry_free(this_obj_conv);
48872 }
48873
48874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
48875         LDKMinFinalCltvExpiry this_ptr_conv;
48876         this_ptr_conv.inner = untag_ptr(this_ptr);
48877         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48879         this_ptr_conv.is_owned = false;
48880         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
48881         return ret_conv;
48882 }
48883
48884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48885         LDKMinFinalCltvExpiry this_ptr_conv;
48886         this_ptr_conv.inner = untag_ptr(this_ptr);
48887         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48889         this_ptr_conv.is_owned = false;
48890         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
48891 }
48892
48893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
48894         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
48895         int64_t ret_ref = 0;
48896         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48897         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48898         return ret_ref;
48899 }
48900
48901 static inline uint64_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
48902         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
48903         int64_t ret_ref = 0;
48904         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48905         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48906         return ret_ref;
48907 }
48908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48909         LDKMinFinalCltvExpiry arg_conv;
48910         arg_conv.inner = untag_ptr(arg);
48911         arg_conv.is_owned = ptr_is_owned(arg);
48912         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48913         arg_conv.is_owned = false;
48914         int64_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
48915         return ret_conv;
48916 }
48917
48918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48919         LDKMinFinalCltvExpiry orig_conv;
48920         orig_conv.inner = untag_ptr(orig);
48921         orig_conv.is_owned = ptr_is_owned(orig);
48922         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48923         orig_conv.is_owned = false;
48924         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
48925         int64_t ret_ref = 0;
48926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48927         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48928         return ret_ref;
48929 }
48930
48931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
48932         LDKMinFinalCltvExpiry o_conv;
48933         o_conv.inner = untag_ptr(o);
48934         o_conv.is_owned = ptr_is_owned(o);
48935         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48936         o_conv.is_owned = false;
48937         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
48938         return ret_conv;
48939 }
48940
48941 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48942         LDKMinFinalCltvExpiry a_conv;
48943         a_conv.inner = untag_ptr(a);
48944         a_conv.is_owned = ptr_is_owned(a);
48945         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48946         a_conv.is_owned = false;
48947         LDKMinFinalCltvExpiry b_conv;
48948         b_conv.inner = untag_ptr(b);
48949         b_conv.is_owned = ptr_is_owned(b);
48950         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48951         b_conv.is_owned = false;
48952         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
48953         return ret_conv;
48954 }
48955
48956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
48957         if (!ptr_is_owned(this_ptr)) return;
48958         void* this_ptr_ptr = untag_ptr(this_ptr);
48959         CHECK_ACCESS(this_ptr_ptr);
48960         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
48961         FREE(untag_ptr(this_ptr));
48962         Fallback_free(this_ptr_conv);
48963 }
48964
48965 static inline uint64_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
48966         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48967         *ret_copy = Fallback_clone(arg);
48968         int64_t ret_ref = tag_ptr(ret_copy, true);
48969         return ret_ref;
48970 }
48971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48972         LDKFallback* arg_conv = (LDKFallback*)untag_ptr(arg);
48973         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
48974         return ret_conv;
48975 }
48976
48977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48978         LDKFallback* orig_conv = (LDKFallback*)untag_ptr(orig);
48979         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48980         *ret_copy = Fallback_clone(orig_conv);
48981         int64_t ret_ref = tag_ptr(ret_copy, true);
48982         return ret_ref;
48983 }
48984
48985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
48986         
48987         LDKCVec_u8Z program_ref;
48988         program_ref.datalen = (*env)->GetArrayLength(env, program);
48989         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
48990         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
48991         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
48992         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
48993         int64_t ret_ref = tag_ptr(ret_copy, true);
48994         return ret_ref;
48995 }
48996
48997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
48998         LDKTwentyBytes a_ref;
48999         CHECK((*env)->GetArrayLength(env, a) == 20);
49000         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
49001         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
49002         *ret_copy = Fallback_pub_key_hash(a_ref);
49003         int64_t ret_ref = tag_ptr(ret_copy, true);
49004         return ret_ref;
49005 }
49006
49007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
49008         LDKTwentyBytes a_ref;
49009         CHECK((*env)->GetArrayLength(env, a) == 20);
49010         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
49011         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
49012         *ret_copy = Fallback_script_hash(a_ref);
49013         int64_t ret_ref = tag_ptr(ret_copy, true);
49014         return ret_ref;
49015 }
49016
49017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
49018         LDKFallback* o_conv = (LDKFallback*)untag_ptr(o);
49019         int64_t ret_conv = Fallback_hash(o_conv);
49020         return ret_conv;
49021 }
49022
49023 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49024         LDKFallback* a_conv = (LDKFallback*)untag_ptr(a);
49025         LDKFallback* b_conv = (LDKFallback*)untag_ptr(b);
49026         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
49027         return ret_conv;
49028 }
49029
49030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49031         LDKInvoiceSignature this_obj_conv;
49032         this_obj_conv.inner = untag_ptr(this_obj);
49033         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49035         InvoiceSignature_free(this_obj_conv);
49036 }
49037
49038 static inline uint64_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
49039         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
49040         int64_t ret_ref = 0;
49041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49042         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49043         return ret_ref;
49044 }
49045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49046         LDKInvoiceSignature arg_conv;
49047         arg_conv.inner = untag_ptr(arg);
49048         arg_conv.is_owned = ptr_is_owned(arg);
49049         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49050         arg_conv.is_owned = false;
49051         int64_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
49052         return ret_conv;
49053 }
49054
49055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49056         LDKInvoiceSignature orig_conv;
49057         orig_conv.inner = untag_ptr(orig);
49058         orig_conv.is_owned = ptr_is_owned(orig);
49059         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49060         orig_conv.is_owned = false;
49061         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
49062         int64_t ret_ref = 0;
49063         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49064         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49065         return ret_ref;
49066 }
49067
49068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1hash(JNIEnv *env, jclass clz, int64_t o) {
49069         LDKInvoiceSignature o_conv;
49070         o_conv.inner = untag_ptr(o);
49071         o_conv.is_owned = ptr_is_owned(o);
49072         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49073         o_conv.is_owned = false;
49074         int64_t ret_conv = InvoiceSignature_hash(&o_conv);
49075         return ret_conv;
49076 }
49077
49078 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49079         LDKInvoiceSignature a_conv;
49080         a_conv.inner = untag_ptr(a);
49081         a_conv.is_owned = ptr_is_owned(a);
49082         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49083         a_conv.is_owned = false;
49084         LDKInvoiceSignature b_conv;
49085         b_conv.inner = untag_ptr(b);
49086         b_conv.is_owned = ptr_is_owned(b);
49087         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49088         b_conv.is_owned = false;
49089         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
49090         return ret_conv;
49091 }
49092
49093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49094         LDKPrivateRoute this_obj_conv;
49095         this_obj_conv.inner = untag_ptr(this_obj);
49096         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49098         PrivateRoute_free(this_obj_conv);
49099 }
49100
49101 static inline uint64_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
49102         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
49103         int64_t ret_ref = 0;
49104         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49105         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49106         return ret_ref;
49107 }
49108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49109         LDKPrivateRoute arg_conv;
49110         arg_conv.inner = untag_ptr(arg);
49111         arg_conv.is_owned = ptr_is_owned(arg);
49112         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49113         arg_conv.is_owned = false;
49114         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
49115         return ret_conv;
49116 }
49117
49118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49119         LDKPrivateRoute orig_conv;
49120         orig_conv.inner = untag_ptr(orig);
49121         orig_conv.is_owned = ptr_is_owned(orig);
49122         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49123         orig_conv.is_owned = false;
49124         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
49125         int64_t ret_ref = 0;
49126         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49127         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49128         return ret_ref;
49129 }
49130
49131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
49132         LDKPrivateRoute o_conv;
49133         o_conv.inner = untag_ptr(o);
49134         o_conv.is_owned = ptr_is_owned(o);
49135         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49136         o_conv.is_owned = false;
49137         int64_t ret_conv = PrivateRoute_hash(&o_conv);
49138         return ret_conv;
49139 }
49140
49141 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49142         LDKPrivateRoute a_conv;
49143         a_conv.inner = untag_ptr(a);
49144         a_conv.is_owned = ptr_is_owned(a);
49145         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49146         a_conv.is_owned = false;
49147         LDKPrivateRoute b_conv;
49148         b_conv.inner = untag_ptr(b);
49149         b_conv.is_owned = ptr_is_owned(b);
49150         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49151         b_conv.is_owned = false;
49152         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
49153         return ret_conv;
49154 }
49155
49156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
49157         LDKSignedRawInvoice this_arg_conv;
49158         this_arg_conv.inner = untag_ptr(this_arg);
49159         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49161         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
49162         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
49163         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
49164         return tag_ptr(ret_conv, true);
49165 }
49166
49167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
49168         LDKSignedRawInvoice this_arg_conv;
49169         this_arg_conv.inner = untag_ptr(this_arg);
49170         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49172         this_arg_conv.is_owned = false;
49173         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
49174         int64_t ret_ref = 0;
49175         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49176         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49177         return ret_ref;
49178 }
49179
49180 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
49181         LDKSignedRawInvoice this_arg_conv;
49182         this_arg_conv.inner = untag_ptr(this_arg);
49183         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49185         this_arg_conv.is_owned = false;
49186         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
49187         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_signable_hash(&this_arg_conv));
49188         return ret_arr;
49189 }
49190
49191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
49192         LDKSignedRawInvoice this_arg_conv;
49193         this_arg_conv.inner = untag_ptr(this_arg);
49194         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49196         this_arg_conv.is_owned = false;
49197         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
49198         int64_t ret_ref = 0;
49199         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49200         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49201         return ret_ref;
49202 }
49203
49204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
49205         LDKSignedRawInvoice this_arg_conv;
49206         this_arg_conv.inner = untag_ptr(this_arg);
49207         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49209         this_arg_conv.is_owned = false;
49210         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
49211         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
49212         return tag_ptr(ret_conv, true);
49213 }
49214
49215 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
49216         LDKSignedRawInvoice this_arg_conv;
49217         this_arg_conv.inner = untag_ptr(this_arg);
49218         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49220         this_arg_conv.is_owned = false;
49221         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
49222         return ret_conv;
49223 }
49224
49225 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
49226         LDKRawInvoice this_arg_conv;
49227         this_arg_conv.inner = untag_ptr(this_arg);
49228         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49230         this_arg_conv.is_owned = false;
49231         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
49232         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_signable_hash(&this_arg_conv).data);
49233         return ret_arr;
49234 }
49235
49236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
49237         LDKRawInvoice this_arg_conv;
49238         this_arg_conv.inner = untag_ptr(this_arg);
49239         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49241         this_arg_conv.is_owned = false;
49242         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
49243         int64_t ret_ref = 0;
49244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49245         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49246         return ret_ref;
49247 }
49248
49249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
49250         LDKRawInvoice this_arg_conv;
49251         this_arg_conv.inner = untag_ptr(this_arg);
49252         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49254         this_arg_conv.is_owned = false;
49255         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
49256         int64_t ret_ref = 0;
49257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49258         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49259         return ret_ref;
49260 }
49261
49262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
49263         LDKRawInvoice this_arg_conv;
49264         this_arg_conv.inner = untag_ptr(this_arg);
49265         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49267         this_arg_conv.is_owned = false;
49268         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
49269         int64_t ret_ref = 0;
49270         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49271         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49272         return ret_ref;
49273 }
49274
49275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
49276         LDKRawInvoice this_arg_conv;
49277         this_arg_conv.inner = untag_ptr(this_arg);
49278         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49280         this_arg_conv.is_owned = false;
49281         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
49282         int64_t ret_ref = 0;
49283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49284         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49285         return ret_ref;
49286 }
49287
49288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
49289         LDKRawInvoice this_arg_conv;
49290         this_arg_conv.inner = untag_ptr(this_arg);
49291         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49293         this_arg_conv.is_owned = false;
49294         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
49295         int64_t ret_ref = 0;
49296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49297         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49298         return ret_ref;
49299 }
49300
49301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
49302         LDKRawInvoice this_arg_conv;
49303         this_arg_conv.inner = untag_ptr(this_arg);
49304         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49306         this_arg_conv.is_owned = false;
49307         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
49308         int64_t ret_ref = 0;
49309         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49310         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49311         return ret_ref;
49312 }
49313
49314 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
49315         LDKRawInvoice this_arg_conv;
49316         this_arg_conv.inner = untag_ptr(this_arg);
49317         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49319         this_arg_conv.is_owned = false;
49320         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
49321         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
49322         return ret_arr;
49323 }
49324
49325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
49326         LDKRawInvoice this_arg_conv;
49327         this_arg_conv.inner = untag_ptr(this_arg);
49328         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49330         this_arg_conv.is_owned = false;
49331         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
49332         int64_t ret_ref = 0;
49333         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49334         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49335         return ret_ref;
49336 }
49337
49338 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
49339         LDKRawInvoice this_arg_conv;
49340         this_arg_conv.inner = untag_ptr(this_arg);
49341         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49343         this_arg_conv.is_owned = false;
49344         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
49345         int64_tArray ret_arr = NULL;
49346         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
49347         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
49348         for (size_t o = 0; o < ret_var.datalen; o++) {
49349                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
49350                 int64_t ret_conv_14_ref = 0;
49351                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
49352                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
49353                 ret_arr_ptr[o] = ret_conv_14_ref;
49354         }
49355         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
49356         FREE(ret_var.data);
49357         return ret_arr;
49358 }
49359
49360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
49361         LDKRawInvoice this_arg_conv;
49362         this_arg_conv.inner = untag_ptr(this_arg);
49363         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49365         this_arg_conv.is_owned = false;
49366         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
49367         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
49368         int64_t ret_ref = tag_ptr(ret_copy, true);
49369         return ret_ref;
49370 }
49371
49372 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
49373         LDKRawInvoice this_arg_conv;
49374         this_arg_conv.inner = untag_ptr(this_arg);
49375         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49377         this_arg_conv.is_owned = false;
49378         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
49379         return ret_conv;
49380 }
49381
49382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
49383         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
49384         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
49385         return tag_ptr(ret_conv, true);
49386 }
49387
49388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
49389         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
49390         *ret_conv = PositiveTimestamp_from_system_time(time);
49391         return tag_ptr(ret_conv, true);
49392 }
49393
49394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
49395         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
49396         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
49397         return tag_ptr(ret_conv, true);
49398 }
49399
49400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
49401         LDKPositiveTimestamp this_arg_conv;
49402         this_arg_conv.inner = untag_ptr(this_arg);
49403         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49405         this_arg_conv.is_owned = false;
49406         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
49407         return ret_conv;
49408 }
49409
49410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
49411         LDKPositiveTimestamp this_arg_conv;
49412         this_arg_conv.inner = untag_ptr(this_arg);
49413         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49415         this_arg_conv.is_owned = false;
49416         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
49417         return ret_conv;
49418 }
49419
49420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
49421         LDKPositiveTimestamp this_arg_conv;
49422         this_arg_conv.inner = untag_ptr(this_arg);
49423         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49425         this_arg_conv.is_owned = false;
49426         int64_t ret_conv = PositiveTimestamp_as_time(&this_arg_conv);
49427         return ret_conv;
49428 }
49429
49430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
49431         LDKInvoice this_arg_conv;
49432         this_arg_conv.inner = untag_ptr(this_arg);
49433         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49435         this_arg_conv = Invoice_clone(&this_arg_conv);
49436         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
49437         int64_t ret_ref = 0;
49438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49439         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49440         return ret_ref;
49441 }
49442
49443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
49444         LDKInvoice this_arg_conv;
49445         this_arg_conv.inner = untag_ptr(this_arg);
49446         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49448         this_arg_conv.is_owned = false;
49449         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
49450         *ret_conv = Invoice_check_signature(&this_arg_conv);
49451         return tag_ptr(ret_conv, true);
49452 }
49453
49454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
49455         LDKSignedRawInvoice signed_invoice_conv;
49456         signed_invoice_conv.inner = untag_ptr(signed_invoice);
49457         signed_invoice_conv.is_owned = ptr_is_owned(signed_invoice);
49458         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
49459         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
49460         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
49461         *ret_conv = Invoice_from_signed(signed_invoice_conv);
49462         return tag_ptr(ret_conv, true);
49463 }
49464
49465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
49466         LDKInvoice this_arg_conv;
49467         this_arg_conv.inner = untag_ptr(this_arg);
49468         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49470         this_arg_conv.is_owned = false;
49471         int64_t ret_conv = Invoice_timestamp(&this_arg_conv);
49472         return ret_conv;
49473 }
49474
49475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
49476         LDKInvoice this_arg_conv;
49477         this_arg_conv.inner = untag_ptr(this_arg);
49478         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49480         this_arg_conv.is_owned = false;
49481         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
49482         return ret_conv;
49483 }
49484
49485 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
49486         LDKInvoice this_arg_conv;
49487         this_arg_conv.inner = untag_ptr(this_arg);
49488         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49490         this_arg_conv.is_owned = false;
49491         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
49492         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
49493         return ret_arr;
49494 }
49495
49496 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
49497         LDKInvoice this_arg_conv;
49498         this_arg_conv.inner = untag_ptr(this_arg);
49499         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49501         this_arg_conv.is_owned = false;
49502         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
49503         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
49504         return ret_arr;
49505 }
49506
49507 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
49508         LDKInvoice this_arg_conv;
49509         this_arg_conv.inner = untag_ptr(this_arg);
49510         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49512         this_arg_conv.is_owned = false;
49513         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
49514         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
49515         return ret_arr;
49516 }
49517
49518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
49519         LDKInvoice this_arg_conv;
49520         this_arg_conv.inner = untag_ptr(this_arg);
49521         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49523         this_arg_conv.is_owned = false;
49524         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
49525         int64_t ret_ref = 0;
49526         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49527         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49528         return ret_ref;
49529 }
49530
49531 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
49532         LDKInvoice this_arg_conv;
49533         this_arg_conv.inner = untag_ptr(this_arg);
49534         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49536         this_arg_conv.is_owned = false;
49537         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
49538         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
49539         return ret_arr;
49540 }
49541
49542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
49543         LDKInvoice this_arg_conv;
49544         this_arg_conv.inner = untag_ptr(this_arg);
49545         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49547         this_arg_conv.is_owned = false;
49548         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
49549         return ret_conv;
49550 }
49551
49552 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
49553         LDKInvoice this_arg_conv;
49554         this_arg_conv.inner = untag_ptr(this_arg);
49555         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49557         this_arg_conv.is_owned = false;
49558         jboolean ret_conv = Invoice_is_expired(&this_arg_conv);
49559         return ret_conv;
49560 }
49561
49562 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
49563         LDKInvoice this_arg_conv;
49564         this_arg_conv.inner = untag_ptr(this_arg);
49565         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49567         this_arg_conv.is_owned = false;
49568         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
49569         return ret_conv;
49570 }
49571
49572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
49573         LDKInvoice this_arg_conv;
49574         this_arg_conv.inner = untag_ptr(this_arg);
49575         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49577         this_arg_conv.is_owned = false;
49578         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
49579         return ret_conv;
49580 }
49581
49582 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
49583         LDKInvoice this_arg_conv;
49584         this_arg_conv.inner = untag_ptr(this_arg);
49585         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49587         this_arg_conv.is_owned = false;
49588         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
49589         int64_tArray ret_arr = NULL;
49590         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
49591         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
49592         for (size_t o = 0; o < ret_var.datalen; o++) {
49593                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
49594                 int64_t ret_conv_14_ref = 0;
49595                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
49596                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
49597                 ret_arr_ptr[o] = ret_conv_14_ref;
49598         }
49599         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
49600         FREE(ret_var.data);
49601         return ret_arr;
49602 }
49603
49604 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
49605         LDKInvoice this_arg_conv;
49606         this_arg_conv.inner = untag_ptr(this_arg);
49607         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49609         this_arg_conv.is_owned = false;
49610         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
49611         int64_tArray ret_arr = NULL;
49612         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
49613         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
49614         for (size_t l = 0; l < ret_var.datalen; l++) {
49615                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
49616                 int64_t ret_conv_11_ref = 0;
49617                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
49618                 ret_conv_11_ref = tag_ptr(ret_conv_11_var.inner, ret_conv_11_var.is_owned);
49619                 ret_arr_ptr[l] = ret_conv_11_ref;
49620         }
49621         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
49622         FREE(ret_var.data);
49623         return ret_arr;
49624 }
49625
49626 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
49627         LDKInvoice this_arg_conv;
49628         this_arg_conv.inner = untag_ptr(this_arg);
49629         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49631         this_arg_conv.is_owned = false;
49632         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
49633         return ret_conv;
49634 }
49635
49636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
49637         LDKInvoice this_arg_conv;
49638         this_arg_conv.inner = untag_ptr(this_arg);
49639         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49641         this_arg_conv.is_owned = false;
49642         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
49643         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
49644         int64_t ret_ref = tag_ptr(ret_copy, true);
49645         return ret_ref;
49646 }
49647
49648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
49649         LDKStr description_conv = java_to_owned_str(env, description);
49650         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
49651         *ret_conv = Description_new(description_conv);
49652         return tag_ptr(ret_conv, true);
49653 }
49654
49655 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
49656         LDKDescription this_arg_conv;
49657         this_arg_conv.inner = untag_ptr(this_arg);
49658         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49660         this_arg_conv = Description_clone(&this_arg_conv);
49661         LDKStr ret_str = Description_into_inner(this_arg_conv);
49662         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49663         Str_free(ret_str);
49664         return ret_conv;
49665 }
49666
49667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
49668         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
49669         int64_t ret_ref = 0;
49670         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49671         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49672         return ret_ref;
49673 }
49674
49675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
49676         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
49677         int64_t ret_ref = 0;
49678         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49679         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49680         return ret_ref;
49681 }
49682
49683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
49684         LDKExpiryTime this_arg_conv;
49685         this_arg_conv.inner = untag_ptr(this_arg);
49686         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49688         this_arg_conv.is_owned = false;
49689         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
49690         return ret_conv;
49691 }
49692
49693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
49694         LDKExpiryTime this_arg_conv;
49695         this_arg_conv.inner = untag_ptr(this_arg);
49696         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49698         this_arg_conv.is_owned = false;
49699         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
49700         return ret_conv;
49701 }
49702
49703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
49704         LDKRouteHint hops_conv;
49705         hops_conv.inner = untag_ptr(hops);
49706         hops_conv.is_owned = ptr_is_owned(hops);
49707         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
49708         hops_conv = RouteHint_clone(&hops_conv);
49709         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
49710         *ret_conv = PrivateRoute_new(hops_conv);
49711         return tag_ptr(ret_conv, true);
49712 }
49713
49714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
49715         LDKPrivateRoute this_arg_conv;
49716         this_arg_conv.inner = untag_ptr(this_arg);
49717         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49719         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
49720         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
49721         int64_t ret_ref = 0;
49722         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49723         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49724         return ret_ref;
49725 }
49726
49727 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49728         LDKCreationError* orig_conv = (LDKCreationError*)untag_ptr(orig);
49729         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
49730         return ret_conv;
49731 }
49732
49733 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
49734         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
49735         return ret_conv;
49736 }
49737
49738 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
49739         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
49740         return ret_conv;
49741 }
49742
49743 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
49744         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
49745         return ret_conv;
49746 }
49747
49748 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
49749         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
49750         return ret_conv;
49751 }
49752
49753 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
49754         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
49755         return ret_conv;
49756 }
49757
49758 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49759         LDKCreationError* a_conv = (LDKCreationError*)untag_ptr(a);
49760         LDKCreationError* b_conv = (LDKCreationError*)untag_ptr(b);
49761         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
49762         return ret_conv;
49763 }
49764
49765 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49766         LDKCreationError* o_conv = (LDKCreationError*)untag_ptr(o);
49767         LDKStr ret_str = CreationError_to_str(o_conv);
49768         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49769         Str_free(ret_str);
49770         return ret_conv;
49771 }
49772
49773 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49774         LDKSemanticError* orig_conv = (LDKSemanticError*)untag_ptr(orig);
49775         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
49776         return ret_conv;
49777 }
49778
49779 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
49780         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
49781         return ret_conv;
49782 }
49783
49784 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
49785         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
49786         return ret_conv;
49787 }
49788
49789 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
49790         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
49791         return ret_conv;
49792 }
49793
49794 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
49795         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
49796         return ret_conv;
49797 }
49798
49799 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
49800         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
49801         return ret_conv;
49802 }
49803
49804 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
49805         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
49806         return ret_conv;
49807 }
49808
49809 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
49810         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
49811         return ret_conv;
49812 }
49813
49814 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
49815         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
49816         return ret_conv;
49817 }
49818
49819 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
49820         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
49821         return ret_conv;
49822 }
49823
49824 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
49825         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
49826         return ret_conv;
49827 }
49828
49829 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49830         LDKSemanticError* a_conv = (LDKSemanticError*)untag_ptr(a);
49831         LDKSemanticError* b_conv = (LDKSemanticError*)untag_ptr(b);
49832         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
49833         return ret_conv;
49834 }
49835
49836 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49837         LDKSemanticError* o_conv = (LDKSemanticError*)untag_ptr(o);
49838         LDKStr ret_str = SemanticError_to_str(o_conv);
49839         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49840         Str_free(ret_str);
49841         return ret_conv;
49842 }
49843
49844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49845         if (!ptr_is_owned(this_ptr)) return;
49846         void* this_ptr_ptr = untag_ptr(this_ptr);
49847         CHECK_ACCESS(this_ptr_ptr);
49848         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
49849         FREE(untag_ptr(this_ptr));
49850         SignOrCreationError_free(this_ptr_conv);
49851 }
49852
49853 static inline uint64_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
49854         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
49855         *ret_copy = SignOrCreationError_clone(arg);
49856         int64_t ret_ref = tag_ptr(ret_copy, true);
49857         return ret_ref;
49858 }
49859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49860         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)untag_ptr(arg);
49861         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
49862         return ret_conv;
49863 }
49864
49865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49866         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)untag_ptr(orig);
49867         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
49868         *ret_copy = SignOrCreationError_clone(orig_conv);
49869         int64_t ret_ref = tag_ptr(ret_copy, true);
49870         return ret_ref;
49871 }
49872
49873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
49874         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
49875         *ret_copy = SignOrCreationError_sign_error();
49876         int64_t ret_ref = tag_ptr(ret_copy, true);
49877         return ret_ref;
49878 }
49879
49880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
49881         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
49882         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
49883         *ret_copy = SignOrCreationError_creation_error(a_conv);
49884         int64_t ret_ref = tag_ptr(ret_copy, true);
49885         return ret_ref;
49886 }
49887
49888 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49889         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)untag_ptr(a);
49890         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)untag_ptr(b);
49891         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
49892         return ret_conv;
49893 }
49894
49895 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
49896         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)untag_ptr(o);
49897         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
49898         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
49899         Str_free(ret_str);
49900         return ret_conv;
49901 }
49902
49903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49904         LDKInvoicePayer this_obj_conv;
49905         this_obj_conv.inner = untag_ptr(this_obj);
49906         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49908         InvoicePayer_free(this_obj_conv);
49909 }
49910
49911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49912         if (!ptr_is_owned(this_ptr)) return;
49913         void* this_ptr_ptr = untag_ptr(this_ptr);
49914         CHECK_ACCESS(this_ptr_ptr);
49915         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
49916         FREE(untag_ptr(this_ptr));
49917         Payer_free(this_ptr_conv);
49918 }
49919
49920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49921         if (!ptr_is_owned(this_ptr)) return;
49922         void* this_ptr_ptr = untag_ptr(this_ptr);
49923         CHECK_ACCESS(this_ptr_ptr);
49924         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
49925         FREE(untag_ptr(this_ptr));
49926         Router_free(this_ptr_conv);
49927 }
49928
49929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Retry_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49930         if (!ptr_is_owned(this_ptr)) return;
49931         void* this_ptr_ptr = untag_ptr(this_ptr);
49932         CHECK_ACCESS(this_ptr_ptr);
49933         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
49934         FREE(untag_ptr(this_ptr));
49935         Retry_free(this_ptr_conv);
49936 }
49937
49938 static inline uint64_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
49939         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
49940         *ret_copy = Retry_clone(arg);
49941         int64_t ret_ref = tag_ptr(ret_copy, true);
49942         return ret_ref;
49943 }
49944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49945         LDKRetry* arg_conv = (LDKRetry*)untag_ptr(arg);
49946         int64_t ret_conv = Retry_clone_ptr(arg_conv);
49947         return ret_conv;
49948 }
49949
49950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49951         LDKRetry* orig_conv = (LDKRetry*)untag_ptr(orig);
49952         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
49953         *ret_copy = Retry_clone(orig_conv);
49954         int64_t ret_ref = tag_ptr(ret_copy, true);
49955         return ret_ref;
49956 }
49957
49958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1attempts(JNIEnv *env, jclass clz, int64_t a) {
49959         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
49960         *ret_copy = Retry_attempts(a);
49961         int64_t ret_ref = tag_ptr(ret_copy, true);
49962         return ret_ref;
49963 }
49964
49965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1timeout(JNIEnv *env, jclass clz, int64_t a) {
49966         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
49967         *ret_copy = Retry_timeout(a);
49968         int64_t ret_ref = tag_ptr(ret_copy, true);
49969         return ret_ref;
49970 }
49971
49972 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Retry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49973         LDKRetry* a_conv = (LDKRetry*)untag_ptr(a);
49974         LDKRetry* b_conv = (LDKRetry*)untag_ptr(b);
49975         jboolean ret_conv = Retry_eq(a_conv, b_conv);
49976         return ret_conv;
49977 }
49978
49979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1hash(JNIEnv *env, jclass clz, int64_t o) {
49980         LDKRetry* o_conv = (LDKRetry*)untag_ptr(o);
49981         int64_t ret_conv = Retry_hash(o_conv);
49982         return ret_conv;
49983 }
49984
49985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49986         if (!ptr_is_owned(this_ptr)) return;
49987         void* this_ptr_ptr = untag_ptr(this_ptr);
49988         CHECK_ACCESS(this_ptr_ptr);
49989         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
49990         FREE(untag_ptr(this_ptr));
49991         PaymentError_free(this_ptr_conv);
49992 }
49993
49994 static inline uint64_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
49995         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
49996         *ret_copy = PaymentError_clone(arg);
49997         int64_t ret_ref = tag_ptr(ret_copy, true);
49998         return ret_ref;
49999 }
50000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50001         LDKPaymentError* arg_conv = (LDKPaymentError*)untag_ptr(arg);
50002         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
50003         return ret_conv;
50004 }
50005
50006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50007         LDKPaymentError* orig_conv = (LDKPaymentError*)untag_ptr(orig);
50008         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
50009         *ret_copy = PaymentError_clone(orig_conv);
50010         int64_t ret_ref = tag_ptr(ret_copy, true);
50011         return ret_ref;
50012 }
50013
50014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
50015         LDKStr a_conv = java_to_owned_str(env, a);
50016         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
50017         *ret_copy = PaymentError_invoice(a_conv);
50018         int64_t ret_ref = tag_ptr(ret_copy, true);
50019         return ret_ref;
50020 }
50021
50022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
50023         LDKLightningError a_conv;
50024         a_conv.inner = untag_ptr(a);
50025         a_conv.is_owned = ptr_is_owned(a);
50026         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50027         a_conv = LightningError_clone(&a_conv);
50028         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
50029         *ret_copy = PaymentError_routing(a_conv);
50030         int64_t ret_ref = tag_ptr(ret_copy, true);
50031         return ret_ref;
50032 }
50033
50034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
50035         void* a_ptr = untag_ptr(a);
50036         CHECK_ACCESS(a_ptr);
50037         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
50038         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(a));
50039         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
50040         *ret_copy = PaymentError_sending(a_conv);
50041         int64_t ret_ref = tag_ptr(ret_copy, true);
50042         return ret_ref;
50043 }
50044
50045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1new(JNIEnv *env, jclass clz, int64_t payer, int64_t router, int64_t logger, int64_t event_handler, int64_t retry) {
50046         void* payer_ptr = untag_ptr(payer);
50047         CHECK_ACCESS(payer_ptr);
50048         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
50049         if (payer_conv.free == LDKPayer_JCalls_free) {
50050                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50051                 LDKPayer_JCalls_cloned(&payer_conv);
50052         }
50053         void* router_ptr = untag_ptr(router);
50054         CHECK_ACCESS(router_ptr);
50055         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
50056         if (router_conv.free == LDKRouter_JCalls_free) {
50057                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50058                 LDKRouter_JCalls_cloned(&router_conv);
50059         }
50060         void* logger_ptr = untag_ptr(logger);
50061         CHECK_ACCESS(logger_ptr);
50062         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
50063         if (logger_conv.free == LDKLogger_JCalls_free) {
50064                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50065                 LDKLogger_JCalls_cloned(&logger_conv);
50066         }
50067         void* event_handler_ptr = untag_ptr(event_handler);
50068         CHECK_ACCESS(event_handler_ptr);
50069         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
50070         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
50071                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50072                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
50073         }
50074         void* retry_ptr = untag_ptr(retry);
50075         CHECK_ACCESS(retry_ptr);
50076         LDKRetry retry_conv = *(LDKRetry*)(retry_ptr);
50077         retry_conv = Retry_clone((LDKRetry*)untag_ptr(retry));
50078         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, logger_conv, event_handler_conv, retry_conv);
50079         int64_t ret_ref = 0;
50080         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50081         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50082         return ret_ref;
50083 }
50084
50085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
50086         LDKInvoicePayer this_arg_conv;
50087         this_arg_conv.inner = untag_ptr(this_arg);
50088         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50090         this_arg_conv.is_owned = false;
50091         LDKInvoice invoice_conv;
50092         invoice_conv.inner = untag_ptr(invoice);
50093         invoice_conv.is_owned = ptr_is_owned(invoice);
50094         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
50095         invoice_conv.is_owned = false;
50096         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
50097         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
50098         return tag_ptr(ret_conv, true);
50099 }
50100
50101 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) {
50102         LDKInvoicePayer this_arg_conv;
50103         this_arg_conv.inner = untag_ptr(this_arg);
50104         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50106         this_arg_conv.is_owned = false;
50107         LDKInvoice invoice_conv;
50108         invoice_conv.inner = untag_ptr(invoice);
50109         invoice_conv.is_owned = ptr_is_owned(invoice);
50110         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
50111         invoice_conv.is_owned = false;
50112         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
50113         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
50114         return tag_ptr(ret_conv, true);
50115 }
50116
50117 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) {
50118         LDKInvoicePayer this_arg_conv;
50119         this_arg_conv.inner = untag_ptr(this_arg);
50120         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50122         this_arg_conv.is_owned = false;
50123         LDKPublicKey pubkey_ref;
50124         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
50125         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
50126         LDKThirtyTwoBytes payment_preimage_ref;
50127         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
50128         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
50129         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
50130         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
50131         return tag_ptr(ret_conv, true);
50132 }
50133
50134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
50135         LDKInvoicePayer this_arg_conv;
50136         this_arg_conv.inner = untag_ptr(this_arg);
50137         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50139         this_arg_conv.is_owned = false;
50140         unsigned char payment_hash_arr[32];
50141         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
50142         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
50143         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
50144         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
50145 }
50146
50147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
50148         LDKInvoicePayer this_arg_conv;
50149         this_arg_conv.inner = untag_ptr(this_arg);
50150         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50152         this_arg_conv.is_owned = false;
50153         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
50154         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
50155         return tag_ptr(ret_ret, true);
50156 }
50157
50158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50159         LDKInFlightHtlcs this_obj_conv;
50160         this_obj_conv.inner = untag_ptr(this_obj);
50161         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50163         InFlightHtlcs_free(this_obj_conv);
50164 }
50165
50166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1used_1liquidity_1msat(JNIEnv *env, jclass clz, int64_t this_arg, int64_t source, int64_t target, int64_t channel_scid) {
50167         LDKInFlightHtlcs this_arg_conv;
50168         this_arg_conv.inner = untag_ptr(this_arg);
50169         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50171         this_arg_conv.is_owned = false;
50172         LDKNodeId source_conv;
50173         source_conv.inner = untag_ptr(source);
50174         source_conv.is_owned = ptr_is_owned(source);
50175         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
50176         source_conv.is_owned = false;
50177         LDKNodeId target_conv;
50178         target_conv.inner = untag_ptr(target);
50179         target_conv.is_owned = ptr_is_owned(target);
50180         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
50181         target_conv.is_owned = false;
50182         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
50183         *ret_copy = InFlightHtlcs_used_liquidity_msat(&this_arg_conv, &source_conv, &target_conv, channel_scid);
50184         int64_t ret_ref = tag_ptr(ret_copy, true);
50185         return ret_ref;
50186 }
50187
50188 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1write(JNIEnv *env, jclass clz, int64_t obj) {
50189         LDKInFlightHtlcs obj_conv;
50190         obj_conv.inner = untag_ptr(obj);
50191         obj_conv.is_owned = ptr_is_owned(obj);
50192         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50193         obj_conv.is_owned = false;
50194         LDKCVec_u8Z ret_var = InFlightHtlcs_write(&obj_conv);
50195         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50196         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50197         CVec_u8Z_free(ret_var);
50198         return ret_arr;
50199 }
50200
50201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
50202         LDKu8slice ser_ref;
50203         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50204         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50205         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
50206         *ret_conv = InFlightHtlcs_read(ser_ref);
50207         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50208         return tag_ptr(ret_conv, true);
50209 }
50210
50211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1phantom_1invoice(JNIEnv *env, jclass clz, int64_t amt_msat, int8_tArray payment_hash, jstring description, int32_t invoice_expiry_delta_secs, int64_tArray phantom_route_hints, int64_t keys_manager, jclass network) {
50212         void* amt_msat_ptr = untag_ptr(amt_msat);
50213         CHECK_ACCESS(amt_msat_ptr);
50214         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
50215         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
50216         LDKThirtyTwoBytes payment_hash_ref;
50217         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
50218         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
50219         LDKStr description_conv = java_to_owned_str(env, description);
50220         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
50221         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
50222         if (phantom_route_hints_constr.datalen > 0)
50223                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
50224         else
50225                 phantom_route_hints_constr.data = NULL;
50226         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
50227         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
50228                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
50229                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
50230                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
50231                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
50232                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
50233                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
50234                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
50235         }
50236         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
50237         void* keys_manager_ptr = untag_ptr(keys_manager);
50238         CHECK_ACCESS(keys_manager_ptr);
50239         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
50240         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
50241                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50242                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
50243         }
50244         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
50245         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
50246         *ret_conv = create_phantom_invoice(amt_msat_conv, payment_hash_ref, description_conv, invoice_expiry_delta_secs, phantom_route_hints_constr, keys_manager_conv, network_conv);
50247         return tag_ptr(ret_conv, true);
50248 }
50249
50250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1phantom_1invoice_1with_1description_1hash(JNIEnv *env, jclass clz, int64_t amt_msat, int8_tArray payment_hash, int32_t invoice_expiry_delta_secs, int64_t description_hash, int64_tArray phantom_route_hints, int64_t keys_manager, jclass network) {
50251         void* amt_msat_ptr = untag_ptr(amt_msat);
50252         CHECK_ACCESS(amt_msat_ptr);
50253         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
50254         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
50255         LDKThirtyTwoBytes payment_hash_ref;
50256         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
50257         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
50258         LDKSha256 description_hash_conv;
50259         description_hash_conv.inner = untag_ptr(description_hash);
50260         description_hash_conv.is_owned = ptr_is_owned(description_hash);
50261         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
50262         description_hash_conv = Sha256_clone(&description_hash_conv);
50263         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
50264         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
50265         if (phantom_route_hints_constr.datalen > 0)
50266                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
50267         else
50268                 phantom_route_hints_constr.data = NULL;
50269         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
50270         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
50271                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
50272                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
50273                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
50274                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
50275                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
50276                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
50277                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
50278         }
50279         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
50280         void* keys_manager_ptr = untag_ptr(keys_manager);
50281         CHECK_ACCESS(keys_manager_ptr);
50282         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
50283         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
50284                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50285                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
50286         }
50287         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
50288         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
50289         *ret_conv = create_phantom_invoice_with_description_hash(amt_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, description_hash_conv, phantom_route_hints_constr, keys_manager_conv, network_conv);
50290         return tag_ptr(ret_conv, true);
50291 }
50292
50293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, jstring description, int32_t invoice_expiry_delta_secs) {
50294         LDKChannelManager channelmanager_conv;
50295         channelmanager_conv.inner = untag_ptr(channelmanager);
50296         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
50297         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
50298         channelmanager_conv.is_owned = false;
50299         void* keys_manager_ptr = untag_ptr(keys_manager);
50300         CHECK_ACCESS(keys_manager_ptr);
50301         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
50302         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
50303                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50304                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
50305         }
50306         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
50307         void* amt_msat_ptr = untag_ptr(amt_msat);
50308         CHECK_ACCESS(amt_msat_ptr);
50309         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
50310         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
50311         LDKStr description_conv = java_to_owned_str(env, description);
50312         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
50313         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv, invoice_expiry_delta_secs);
50314         return tag_ptr(ret_conv, true);
50315 }
50316
50317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager_1with_1description_1hash(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, int64_t description_hash, int32_t invoice_expiry_delta_secs) {
50318         LDKChannelManager channelmanager_conv;
50319         channelmanager_conv.inner = untag_ptr(channelmanager);
50320         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
50321         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
50322         channelmanager_conv.is_owned = false;
50323         void* keys_manager_ptr = untag_ptr(keys_manager);
50324         CHECK_ACCESS(keys_manager_ptr);
50325         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
50326         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
50327                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50328                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
50329         }
50330         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
50331         void* amt_msat_ptr = untag_ptr(amt_msat);
50332         CHECK_ACCESS(amt_msat_ptr);
50333         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
50334         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
50335         LDKSha256 description_hash_conv;
50336         description_hash_conv.inner = untag_ptr(description_hash);
50337         description_hash_conv.is_owned = ptr_is_owned(description_hash);
50338         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
50339         description_hash_conv = Sha256_clone(&description_hash_conv);
50340         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
50341         *ret_conv = create_invoice_from_channelmanager_with_description_hash(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_hash_conv, invoice_expiry_delta_secs);
50342         return tag_ptr(ret_conv, true);
50343 }
50344
50345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager_1with_1description_1hash_1and_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, int64_t description_hash, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs) {
50346         LDKChannelManager channelmanager_conv;
50347         channelmanager_conv.inner = untag_ptr(channelmanager);
50348         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
50349         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
50350         channelmanager_conv.is_owned = false;
50351         void* keys_manager_ptr = untag_ptr(keys_manager);
50352         CHECK_ACCESS(keys_manager_ptr);
50353         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
50354         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
50355                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50356                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
50357         }
50358         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
50359         void* amt_msat_ptr = untag_ptr(amt_msat);
50360         CHECK_ACCESS(amt_msat_ptr);
50361         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
50362         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
50363         LDKSha256 description_hash_conv;
50364         description_hash_conv.inner = untag_ptr(description_hash);
50365         description_hash_conv.is_owned = ptr_is_owned(description_hash);
50366         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
50367         description_hash_conv = Sha256_clone(&description_hash_conv);
50368         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
50369         *ret_conv = create_invoice_from_channelmanager_with_description_hash_and_duration_since_epoch(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_hash_conv, duration_since_epoch, invoice_expiry_delta_secs);
50370         return tag_ptr(ret_conv, true);
50371 }
50372
50373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager_1and_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, jstring description, int64_t duration_since_epoch, int32_t invoice_expiry_delta_secs) {
50374         LDKChannelManager channelmanager_conv;
50375         channelmanager_conv.inner = untag_ptr(channelmanager);
50376         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
50377         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
50378         channelmanager_conv.is_owned = false;
50379         void* keys_manager_ptr = untag_ptr(keys_manager);
50380         CHECK_ACCESS(keys_manager_ptr);
50381         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
50382         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
50383                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50384                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
50385         }
50386         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
50387         void* amt_msat_ptr = untag_ptr(amt_msat);
50388         CHECK_ACCESS(amt_msat_ptr);
50389         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
50390         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
50391         LDKStr description_conv = java_to_owned_str(env, description);
50392         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
50393         *ret_conv = create_invoice_from_channelmanager_and_duration_since_epoch(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv, duration_since_epoch, invoice_expiry_delta_secs);
50394         return tag_ptr(ret_conv, true);
50395 }
50396
50397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50398         LDKDefaultRouter this_obj_conv;
50399         this_obj_conv.inner = untag_ptr(this_obj);
50400         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50402         DefaultRouter_free(this_obj_conv);
50403 }
50404
50405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t logger, int8_tArray random_seed_bytes, int64_t scorer) {
50406         LDKNetworkGraph network_graph_conv;
50407         network_graph_conv.inner = untag_ptr(network_graph);
50408         network_graph_conv.is_owned = ptr_is_owned(network_graph);
50409         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
50410         network_graph_conv.is_owned = false;
50411         void* logger_ptr = untag_ptr(logger);
50412         CHECK_ACCESS(logger_ptr);
50413         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
50414         if (logger_conv.free == LDKLogger_JCalls_free) {
50415                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50416                 LDKLogger_JCalls_cloned(&logger_conv);
50417         }
50418         LDKThirtyTwoBytes random_seed_bytes_ref;
50419         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
50420         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_ref.data);
50421         void* scorer_ptr = untag_ptr(scorer);
50422         CHECK_ACCESS(scorer_ptr);
50423         LDKLockableScore scorer_conv = *(LDKLockableScore*)(scorer_ptr);
50424         if (scorer_conv.free == LDKLockableScore_JCalls_free) {
50425                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50426                 LDKLockableScore_JCalls_cloned(&scorer_conv);
50427         }
50428         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref, scorer_conv);
50429         int64_t ret_ref = 0;
50430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50431         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50432         return ret_ref;
50433 }
50434
50435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
50436         LDKDefaultRouter this_arg_conv;
50437         this_arg_conv.inner = untag_ptr(this_arg);
50438         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50440         this_arg_conv.is_owned = false;
50441         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
50442         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
50443         return tag_ptr(ret_ret, true);
50444 }
50445
50446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
50447         LDKChannelManager this_arg_conv;
50448         this_arg_conv.inner = untag_ptr(this_arg);
50449         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50451         this_arg_conv.is_owned = false;
50452         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
50453         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
50454         return tag_ptr(ret_ret, true);
50455 }
50456
50457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
50458         LDKStr s_conv = java_to_owned_str(env, s);
50459         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
50460         *ret_conv = SiPrefix_from_str(s_conv);
50461         return tag_ptr(ret_conv, true);
50462 }
50463
50464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
50465         LDKStr s_conv = java_to_owned_str(env, s);
50466         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
50467         *ret_conv = Invoice_from_str(s_conv);
50468         return tag_ptr(ret_conv, true);
50469 }
50470
50471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
50472         LDKStr s_conv = java_to_owned_str(env, s);
50473         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
50474         *ret_conv = SignedRawInvoice_from_str(s_conv);
50475         return tag_ptr(ret_conv, true);
50476 }
50477
50478 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
50479         LDKParseError* o_conv = (LDKParseError*)untag_ptr(o);
50480         LDKStr ret_str = ParseError_to_str(o_conv);
50481         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
50482         Str_free(ret_str);
50483         return ret_conv;
50484 }
50485
50486 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
50487         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)untag_ptr(o);
50488         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
50489         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
50490         Str_free(ret_str);
50491         return ret_conv;
50492 }
50493
50494 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
50495         LDKInvoice o_conv;
50496         o_conv.inner = untag_ptr(o);
50497         o_conv.is_owned = ptr_is_owned(o);
50498         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
50499         o_conv.is_owned = false;
50500         LDKStr ret_str = Invoice_to_str(&o_conv);
50501         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
50502         Str_free(ret_str);
50503         return ret_conv;
50504 }
50505
50506 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
50507         LDKSignedRawInvoice o_conv;
50508         o_conv.inner = untag_ptr(o);
50509         o_conv.is_owned = ptr_is_owned(o);
50510         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
50511         o_conv.is_owned = false;
50512         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
50513         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
50514         Str_free(ret_str);
50515         return ret_conv;
50516 }
50517
50518 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
50519         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
50520         LDKStr ret_str = Currency_to_str(o_conv);
50521         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
50522         Str_free(ret_str);
50523         return ret_conv;
50524 }
50525
50526 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
50527         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
50528         LDKStr ret_str = SiPrefix_to_str(o_conv);
50529         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
50530         Str_free(ret_str);
50531         return ret_conv;
50532 }
50533
50534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50535         LDKRapidGossipSync this_obj_conv;
50536         this_obj_conv.inner = untag_ptr(this_obj);
50537         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50539         RapidGossipSync_free(this_obj_conv);
50540 }
50541
50542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph) {
50543         LDKNetworkGraph network_graph_conv;
50544         network_graph_conv.inner = untag_ptr(network_graph);
50545         network_graph_conv.is_owned = ptr_is_owned(network_graph);
50546         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
50547         network_graph_conv.is_owned = false;
50548         LDKRapidGossipSync ret_var = RapidGossipSync_new(&network_graph_conv);
50549         int64_t ret_ref = 0;
50550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50551         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50552         return ret_ref;
50553 }
50554
50555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1sync_1network_1graph_1with_1file_1path(JNIEnv *env, jclass clz, int64_t this_arg, jstring sync_path) {
50556         LDKRapidGossipSync this_arg_conv;
50557         this_arg_conv.inner = untag_ptr(this_arg);
50558         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50560         this_arg_conv.is_owned = false;
50561         LDKStr sync_path_conv = java_to_owned_str(env, sync_path);
50562         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
50563         *ret_conv = RapidGossipSync_sync_network_graph_with_file_path(&this_arg_conv, sync_path_conv);
50564         return tag_ptr(ret_conv, true);
50565 }
50566
50567 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1is_1initial_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_arg) {
50568         LDKRapidGossipSync this_arg_conv;
50569         this_arg_conv.inner = untag_ptr(this_arg);
50570         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50572         this_arg_conv.is_owned = false;
50573         jboolean ret_conv = RapidGossipSync_is_initial_sync_complete(&this_arg_conv);
50574         return ret_conv;
50575 }
50576
50577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50578         if (!ptr_is_owned(this_ptr)) return;
50579         void* this_ptr_ptr = untag_ptr(this_ptr);
50580         CHECK_ACCESS(this_ptr_ptr);
50581         LDKGraphSyncError this_ptr_conv = *(LDKGraphSyncError*)(this_ptr_ptr);
50582         FREE(untag_ptr(this_ptr));
50583         GraphSyncError_free(this_ptr_conv);
50584 }
50585
50586 static inline uint64_t GraphSyncError_clone_ptr(LDKGraphSyncError *NONNULL_PTR arg) {
50587         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
50588         *ret_copy = GraphSyncError_clone(arg);
50589         int64_t ret_ref = tag_ptr(ret_copy, true);
50590         return ret_ref;
50591 }
50592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50593         LDKGraphSyncError* arg_conv = (LDKGraphSyncError*)untag_ptr(arg);
50594         int64_t ret_conv = GraphSyncError_clone_ptr(arg_conv);
50595         return ret_conv;
50596 }
50597
50598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50599         LDKGraphSyncError* orig_conv = (LDKGraphSyncError*)untag_ptr(orig);
50600         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
50601         *ret_copy = GraphSyncError_clone(orig_conv);
50602         int64_t ret_ref = tag_ptr(ret_copy, true);
50603         return ret_ref;
50604 }
50605
50606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1decode_1error(JNIEnv *env, jclass clz, int64_t a) {
50607         LDKDecodeError a_conv;
50608         a_conv.inner = untag_ptr(a);
50609         a_conv.is_owned = ptr_is_owned(a);
50610         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50611         a_conv = DecodeError_clone(&a_conv);
50612         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
50613         *ret_copy = GraphSyncError_decode_error(a_conv);
50614         int64_t ret_ref = tag_ptr(ret_copy, true);
50615         return ret_ref;
50616 }
50617
50618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1lightning_1error(JNIEnv *env, jclass clz, int64_t a) {
50619         LDKLightningError a_conv;
50620         a_conv.inner = untag_ptr(a);
50621         a_conv.is_owned = ptr_is_owned(a);
50622         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50623         a_conv = LightningError_clone(&a_conv);
50624         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
50625         *ret_copy = GraphSyncError_lightning_error(a_conv);
50626         int64_t ret_ref = tag_ptr(ret_copy, true);
50627         return ret_ref;
50628 }
50629
50630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1update_1network_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray update_data) {
50631         LDKRapidGossipSync this_arg_conv;
50632         this_arg_conv.inner = untag_ptr(this_arg);
50633         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50635         this_arg_conv.is_owned = false;
50636         LDKu8slice update_data_ref;
50637         update_data_ref.datalen = (*env)->GetArrayLength(env, update_data);
50638         update_data_ref.data = (*env)->GetByteArrayElements (env, update_data, NULL);
50639         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
50640         *ret_conv = RapidGossipSync_update_network_graph(&this_arg_conv, update_data_ref);
50641         (*env)->ReleaseByteArrayElements(env, update_data, (int8_t*)update_data_ref.data, 0);
50642         return tag_ptr(ret_conv, true);
50643 }
50644